[CMake] Detecting changed libraries
Nico Galoppo
ngaloppo at gmail.com
Sat Feb 16 10:27:39 EST 2008
Hi,
I have a project set up where I genererate optimized/debug libraries
depending on the build type. In the debug build, a 'd' postfix is
added with CMAKE_DEBUG_POSTFIX. However, when building the unit tests
from the same project tree, the updated link library is not detected
and hence the unit tests are not rebuilt. If I delete the unit test
binaries to force a rebuild, the correct (debug) link library is
linked in. What am I missing here? CMakeLists.txt attached.
Thanks.
=== toplevel CMakeLists.txt
PROJECT(fem)
# Can this be overridden from command line?
SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install)
SET(CMAKE_DEBUG_POSTFIX "d")
FIND_PACKAGE(OpenTissue)
IF(OPENTISSUE_FOUND)
INCLUDE_DIRECTORIES( ${OPENTISSUE_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${OPENTISSUE_LIBRARY_DIRS} )
ADD_DEFINITIONS( ${OPENTISSUE_FLAGS} )
ENDIF(OPENTISSUE_FOUND)
FIND_LIBRARY(BOOST_SERIALIZATION_LIB NAMES boost_serialization PATHS /opt/lib)
# Set up paths such that other programs can find this library
SET(FEM_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
SET(FEM_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
SET(FEM_LIBS fem)
SET(FEM_LIBS_DEBUG femd)
# Make a configure file for external programs
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/femConfig.cmake.in"
"${PROJECT_SOURCE_DIR}/femConfig.cmake"
@ONLY
)
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/fem/include )
SUBDIRS(fem)
SUBDIRS(units)
== fem/CMakeLists.txt
FILE(GLOB FEM_LIBRARY_SOURCES src/*.cpp)
FILE(GLOB FEM_LIBRARY_HEADERS include/fem/*.h)
ADD_LIBRARY(fem ${FEM_LIBRARY_SOURCES} ${FEM_LIBRARY_HEADERS})
INSTALL(TARGETS fem DESTINATION lib)
INSTALL(FILES ${FEM_LIBRARY_HEADERS} DESTINATION include/fem)
== units/CMakeLists.txt
TARGET_LINK_LIBRARIES(unit_fem_stvk
optimized ${FEM_LIBS} debug ${FEM_LIBS_DEBUG}
${OPENTISSUE_LIBS}
${BOOST_SERIALIZATION_LIB})
TARGET_LINK_LIBRARIES(unit_fem_reduced_stvk
optimized ${FEM_LIBS} debug ${FEM_LIBS_DEBUG}
${OPENTISSUE_LIBS}
${BOOST_SERIALIZATION_LIB})
INSTALL(
TARGETS unit_fem_stvk
RUNTIME DESTINATION bin/units
)
INSTALL(
TARGETS unit_fem_reduced_stvk
RUNTIME DESTINATION bin/units
)
--
Nico Galoppo :: http://www.ngaloppo.org
More information about the CMake
mailing list