From 2193cb3fc4317433491330ca58f7ff1f708f4354 Mon Sep 17 00:00:00 2001 From: zmertens Date: Wed, 8 Apr 2015 14:20:44 -0700 Subject: [PATCH] fixed issue with Linux and CMake not finding resource files when launching executable and edited README for Linux more precise building instructions --- CMakeLists.txt | 9 +++------ README.md | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65cab3b..e0034fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,8 @@ foreach(CHAPTER ${CHAPTERS}) target_link_libraries(${DEMO} ${LIBS}) if(WIN32) set_target_properties(${DEMO} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}") + elseif(UNIX) + set_target_properties(${DEMO} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin/${CHAPTER}") endif(WIN32) # copy shader files to build directory file(GLOB SHADERS @@ -127,7 +129,7 @@ foreach(CHAPTER ${CHAPTERS}) # configure_file(${SHADER} "test") add_custom_command(TARGET ${DEMO} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SHADER} $) elseif(UNIX) - file(COPY ${SHADER} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${SHADER} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/${CHAPTER}) endif(WIN32) endforeach(SHADER) @@ -139,8 +141,3 @@ foreach(CHAPTER ${CHAPTERS}) endforeach(CHAPTER) include_directories(${CMAKE_SOURCE_DIR}/includes) - -if(UNIX) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -endif(UNIX) - diff --git a/README.md b/README.md index 60404b3..563d5fe 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ Note that you still have to manually copy the required .DLL files from the /dlls ## Linux building First make sure you have CMake, Git, and GCC by typing as root (sudo) `apt-get install g++ cmake git` and then get the required packages: -Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev` +Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev` . Next, run CMake (preferably CMake-gui). The source directory is LearnOpenGL and specify the build directory as LearnOpenGL/build. Creating the build directory within LearnOpenGL is important for linking to the resource files (it also will be ignored by Git). Hit configure and specify your compiler files (Unix Makefiles are recommended), resolve any missing directories or libraries, and then hit generate. Navigate to the build directory (`cd LearnOpenGL/build`) and type make in the terminal. This should generate the executables in the respective chapter folders. Note that using CodeBlocks or an IDE may have issues running the programs due to problems finding the shader and resource files, however it should still be able to generate the exectuables.