[CMake] Pure template libraries
Eric Noulard
eric.noulard at gmail.com
Wed Nov 12 11:00:32 EST 2008
2008/11/12 Cristóvão Sousa <crisjss at gmail.com>:
> On Wednesday 12 November 2008 12:58:08 "Eric Noulard" <eric.noulard at gmail.com>
> wrote:
>> 2008/11/12 Cristóvão Sousa <crisjss at gmail.com>:
>> >
>> > This works fine, but is a little bit annoying having to place
>> > "include_directories(${PROJECT_SOURCE_DIR}/base)"
>> > in the Exec/CMakeLists.txt file. (because in the real project
>> > I use a lot of pure template libraries which include a lot of
>> > other libraries, and often I don't remember them all.)
>> >
>
>>
>> 1) add them explicitely to your exe sources files:
>>
>> 2) Or may be defining "template lib"
>
> This two doesn't help because I also need to know which are the hpp files
> included by the one the executable includes. (This is true for compiled
> libraries too, right?)
Yes, when executable uses "classical" lib you have to:
TARGET_LINK_LIBRARIES(YOUR_EXE_TARGET YOURLIB1 YOURLIB2) etc...
>> 3) export them somewhere in your build tree and include_directory the
>> choosen place:
>>
>> Libbase/CMakeLists.txt :
>> CONFIGURE_FILE(base.hpp build_include)
this is a mistake one should read:
CONFIGURE_FILE(base.hpp build_include/base.hpp @COPYONLY)
>>
>> Libderiv/CMakeLists.txt :
>> CONFIGURE_FILE(deriv.hpp build_include)
same here:
CONFIGURE_FILE(deriv.hpp build_include/deriv.hpp @COPYONLY)
>> Exec/CMakeLists.txt :
>> include_directories(build_include)
>> set(exec_SRCS main.cpp)
>> add_executable(exec ${exec_SRCS})
>
> This is a little better, however I cannot managed to define "build_include"
build_include in my example was meant to be a directory name located
in the build tree.
CONFIGURE_FILE(deriv.hpp build_include/deriv.hpp @COPYONLY)
should create the directory if needed, if it is not the case you should
file(MAKE_DIRECTORY build_include) before
CONFIGURE_FILE(...
You may specify it using absolute path:
${CMAKE_BINARY_DIR}/build_include
> correctly. I set(BUILD_INCS_DIR ./build_incs), but no good...
Sorry for the wrong tips
--
Erk
More information about the CMake
mailing list