[CMake] Include_directories looks for Boost twice / Problem with if statement
Raymond Wan
rwan.work at gmail.com
Tue Dec 11 03:16:50 EST 2012
Hi Jakub,
On Fri, Dec 7, 2012 at 4:46 PM, Jakub Zakrzewski <jzakrzewski at 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
More information about the CMake
mailing list