Re: [CMake] Include_directories looks for Boost twice / Problem with if statement
Hi Jakub, On Fri, Dec 7, 2012 at 4:46 PM, Jakub Zakrzewski jzakrzew...@e2e.ch wrote: Hi Did you think about something like this: ADD_DEFINITIONS (-DBOOST_ALL_NO_LIB) SET (BOOST_ROOT $ENV{BOOST_ROOT}) SET (Boost_NO_SYSTEM_PATHS ON) SET (Boost_USE_MULTITHREADED ON) SET (Boost_USE_STATIC_RUNTIME OFF) IF (TARGET parent) FIND_PACKAGE (Boost 1.42.0 REQUIRED COMPONENTS system) IF (Boost_FOUND) LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES (parent ${Boost_LIBRARIES}) ENDIF () ENDIF (TARGET parent) How embarrassing...yes, what you suggested of just putting the search in the IF statement worked. Unfortunately, getting it right made me realize I had problems elsewhere in my CMakeLists.txt (in particular, it wasn't conditionally defining the target properly). In the end, I added: IF (${PROJECT_NAME} STREQUAL ) PROJECT (child CXX) ENDIF (${PROJECT_NAME} STREQUAL ) and likewise to the ADD_EXECUTABLE () in all of my CMakeLists.txt. I don't know if this is the right way to do it, but it seems ok so far... Yes, in hindsight, what you suggested was obvious but I was so fixated on something more complicated; the obvious eluded me! Thank you for your help! Ray -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Include_directories looks for Boost twice / Problem with if statement
Hi Did you think about something like this: ADD_DEFINITIONS (-DBOOST_ALL_NO_LIB) SET (BOOST_ROOT $ENV{BOOST_ROOT}) SET (Boost_NO_SYSTEM_PATHS ON) SET (Boost_USE_MULTITHREADED ON) SET (Boost_USE_STATIC_RUNTIME OFF) IF (TARGET parent) FIND_PACKAGE (Boost 1.42.0 REQUIRED COMPONENTS system) IF (Boost_FOUND) LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES (parent ${Boost_LIBRARIES}) ENDIF () ENDIF (TARGET parent) -Original Message- From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of Raymond Wan Sent: Donnerstag, 6. Dezember 2012 18:45 To: cmake@cmake.org Subject: [CMake] Include_directories looks for Boost twice / Problem with if statement Hi all, I have two CMakeFile.txt's for a C++ project where one includes the other. In both cases, I'm searching for Boost. So, to make this easier, suppose I call one project parent and the other child such that parent's CMakefile.txt has: INCLUDE_DIRECTORIES (child) where child is a subdirectory. Both have: ADD_DEFINITIONS (-DBOOST_ALL_NO_LIB) SET (BOOST_ROOT $ENV{BOOST_ROOT}) SET (Boost_NO_SYSTEM_PATHS ON) SET (Boost_USE_MULTITHREADED ON) SET (Boost_USE_STATIC_RUNTIME OFF) FIND_PACKAGE (Boost 1.42.0 REQUIRED COMPONENTS system) IF (Boost_FOUND) IF (TARGET parent) LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES (parent ${Boost_LIBRARIES}) ENDIF (TARGET parent) ENDIF () (In the subdirectory child, I check for the target child instead.) The reason I have to repeat it twice is because both parent and child has a main (). parent has the one for the entire project; if I want to do unit testing on child, then I compile in child's build directory using its main. I hope everything so far is ok. The problem is that when I run the CMakeFile.txt of parent, it ends up checking for Boost twice. There's no harm to it and I had left it alone for a while. Then, I thought I could use an if statement inside child to prevent it from checking again. Inside, child, none of these seem to work: IF (NOT DEFINED Boost_FOUND) IF (NOT Boost_FOUND) So, while my question is about Boost, I guess it is irrelevant to boost...seems to be a problem with my understanding of variables and if statements. Any suggestion on what I'm doing wrong? Or am I going at it wrong and I need to rethink what I'm doing? Thank you! Ray -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] Include_directories looks for Boost twice / Problem with if statement
Hi all, I have two CMakeFile.txt's for a C++ project where one includes the other. In both cases, I'm searching for Boost. So, to make this easier, suppose I call one project parent and the other child such that parent's CMakefile.txt has: INCLUDE_DIRECTORIES (child) where child is a subdirectory. Both have: ADD_DEFINITIONS (-DBOOST_ALL_NO_LIB) SET (BOOST_ROOT $ENV{BOOST_ROOT}) SET (Boost_NO_SYSTEM_PATHS ON) SET (Boost_USE_MULTITHREADED ON) SET (Boost_USE_STATIC_RUNTIME OFF) FIND_PACKAGE (Boost 1.42.0 REQUIRED COMPONENTS system) IF (Boost_FOUND) IF (TARGET parent) LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES (parent ${Boost_LIBRARIES}) ENDIF (TARGET parent) ENDIF () (In the subdirectory child, I check for the target child instead.) The reason I have to repeat it twice is because both parent and child has a main (). parent has the one for the entire project; if I want to do unit testing on child, then I compile in child's build directory using its main. I hope everything so far is ok. The problem is that when I run the CMakeFile.txt of parent, it ends up checking for Boost twice. There's no harm to it and I had left it alone for a while. Then, I thought I could use an if statement inside child to prevent it from checking again. Inside, child, none of these seem to work: IF (NOT DEFINED Boost_FOUND) IF (NOT Boost_FOUND) So, while my question is about Boost, I guess it is irrelevant to boost...seems to be a problem with my understanding of variables and if statements. Any suggestion on what I'm doing wrong? Or am I going at it wrong and I need to rethink what I'm doing? Thank you! Ray -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake