# HG changeset patch # User Akos Ladanyi # Date 2009-03-16 14:51:32 # Node ID ba659d676331942fad3d346499583b34a701de0d # Parent 94387da47f7967d81fd70ad05e038d96a637c934 Make it possible to use LEMON as a CMake subproject (#240) diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ PROJECT(${PROJECT_NAME}) -SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) INCLUDE(FindDoxygen) INCLUDE(FindGhostscript) @@ -38,10 +38,12 @@ ENABLE_TESTING() ADD_SUBDIRECTORY(lemon) -ADD_SUBDIRECTORY(demo) -ADD_SUBDIRECTORY(tools) -ADD_SUBDIRECTORY(doc) -ADD_SUBDIRECTORY(test) +IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) + ADD_SUBDIRECTORY(demo) + ADD_SUBDIRECTORY(tools) + ADD_SUBDIRECTORY(doc) + ADD_SUBDIRECTORY(test) +ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) IF(WIN32) SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,9 +1,9 @@ INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} ) -LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon) +LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) SET(DEMOS arg_parser_demo diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,11 +1,11 @@ SET(PACKAGE_NAME ${PROJECT_NAME}) SET(PACKAGE_VERSION ${PROJECT_VERSION}) -SET(abs_top_srcdir ${CMAKE_SOURCE_DIR}) -SET(abs_top_builddir ${CMAKE_BINARY_DIR}) +SET(abs_top_srcdir ${PROJECT_SOURCE_DIR}) +SET(abs_top_builddir ${PROJECT_BINARY_DIR}) CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in - ${CMAKE_BINARY_DIR}/doc/Doxyfile + ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in + ${PROJECT_BINARY_DIR}/doc/Doxyfile @ONLY) IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE) diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt --- a/lemon/CMakeLists.txt +++ b/lemon/CMakeLists.txt @@ -1,6 +1,6 @@ INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} ) CONFIGURE_FILE( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,13 +1,13 @@ INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} ) IF(HAVE_GLPK) INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIR}) ENDIF(HAVE_GLPK) -LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon) +LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) SET(TESTS adaptors_test diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,9 +1,9 @@ INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} ) -LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon) +LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) ADD_EXECUTABLE(lgf-gen lgf-gen.cc) TARGET_LINK_LIBRARIES(lgf-gen lemon) @@ -22,7 +22,7 @@ IF(NOT WIN32) INSTALL( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh - RUNTIME DESTINATION bin + PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh + DESTINATION bin COMPONENT bin) ENDIF(NOT WIN32)