Backport the CMAKE related changesets from the main branch
authorAlpar Juttner <alpar@cs.elte.hu>
Wed, 25 Aug 2010 21:34:58 +0200
changeset 90416d466589b54
parent 903 8ae2627aba1a
child 905 d149eaf24638
child 906 021e232acda2
child 913 64260c0f58eb
Backport the CMAKE related changesets from the main branch

[e20fecd1945f] Add check target for CMake (#388)
[e74b5db4f2c6] Put the output of chg-len.py in the version string (#389)
[7d166b8b8018] Safer call of ./scripts/chg-len.py on Windows (#389)
[659ba4805a48] Make CMAKE config more consistent with configure.ac (#390)
[63e4468c680e] Add 'Maintainer' CMAKE build type (#388, #390)
[a725503acfe9] Allow CPACK configuration on all platforms
[10242c611190] Create and install lemon.pc (#393)
[48e29534cf03] The deafult target doesn't build lp_test and mip_test (#388)
[0fbbdd578c06] Full path for DoxygenLayout.xml in Doxyfile.in (#395)
[481496e6d71f] SOURCE_BROWSER Doxygen switch is configurable from CMAKE (#395)
[09282720100b] update-external-tags CMAKE target (#395)
CMakeLists.txt
doc/CMakeLists.txt
doc/Doxyfile.in
lemon/CMakeLists.txt
lemon/lemon.pc.cmake
test/CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Sat Oct 10 08:19:26 2009 +0200
     1.2 +++ b/CMakeLists.txt	Wed Aug 25 21:34:58 2010 +0200
     1.3 @@ -3,12 +3,22 @@
     1.4  SET(PROJECT_NAME "LEMON")
     1.5  PROJECT(${PROJECT_NAME})
     1.6  
     1.7 +INCLUDE(FindPythonInterp)
     1.8 +INCLUDE(FindWget)
     1.9 +
    1.10  IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.11    INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.12  ELSEIF(DEFINED ENV{LEMON_VERSION})
    1.13    SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
    1.14  ELSE()
    1.15    EXECUTE_PROCESS(
    1.16 +    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
    1.17 +    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    1.18 +    OUTPUT_VARIABLE HG_REVISION_PATH
    1.19 +    ERROR_QUIET
    1.20 +    OUTPUT_STRIP_TRAILING_WHITESPACE
    1.21 +  )
    1.22 +  EXECUTE_PROCESS(
    1.23      COMMAND hg id -i
    1.24      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    1.25      OUTPUT_VARIABLE HG_REVISION
    1.26 @@ -16,9 +26,15 @@
    1.27      OUTPUT_STRIP_TRAILING_WHITESPACE
    1.28    )
    1.29    IF(HG_REVISION STREQUAL "")
    1.30 -    SET(HG_REVISION "hg-tip")
    1.31 +    SET(HG_REVISION_ID "hg-tip")
    1.32 +  ELSE()
    1.33 +    IF(HG_REVISION_PATH STREQUAL "")
    1.34 +      SET(HG_REVISION_ID ${HG_REVISION})
    1.35 +    ELSE()
    1.36 +      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
    1.37 +    ENDIF()
    1.38    ENDIF()
    1.39 -  SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
    1.40 +  SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.")
    1.41  ENDIF()
    1.42  
    1.43  SET(PROJECT_VERSION ${LEMON_VERSION})
    1.44 @@ -31,12 +47,81 @@
    1.45  FIND_PACKAGE(CPLEX)
    1.46  FIND_PACKAGE(COIN)
    1.47  
    1.48 +IF(DEFINED ENV{LEMON_CXX_WARNING})
    1.49 +  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
    1.50 +ELSE()
    1.51 +  IF(CMAKE_COMPILER_IS_GNUCXX)
    1.52 +    SET(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
    1.53 +    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
    1.54 +    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
    1.55 +  ELSEIF(MSVC)
    1.56 +    # This part is unnecessary 'casue the same is set by the lemon/core.h.
    1.57 +    # Still keep it as an example.
    1.58 +    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
    1.59 +    # Suppressed warnings:
    1.60 +    # C4250: 'class1' : inherits 'class2::member' via dominance
    1.61 +    # C4355: 'this' : used in base member initializer list
    1.62 +    # C4503: 'function' : decorated name length exceeded, name was truncated
    1.63 +    # C4800: 'type' : forcing value to bool 'true' or 'false'
    1.64 +    #        (performance warning)
    1.65 +    # C4996: 'function': was declared deprecated
    1.66 +  ELSE()
    1.67 +    SET(CXX_WARNING "-Wall -W")
    1.68 +  ENDIF()
    1.69 +ENDIF()
    1.70 +SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
    1.71 +
    1.72 +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
    1.73 +
    1.74 +SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb" CACHE STRING
    1.75 +    "Flags used by the C++ compiler during maintainer builds."
    1.76 +    FORCE )
    1.77 +SET( CMAKE_C_FLAGS_MAINTAINER "-Werror" CACHE STRING
    1.78 +    "Flags used by the C compiler during maintainer builds."
    1.79 +    FORCE )
    1.80 +SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.81 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.82 +    "Flags used for linking binaries during maintainer builds."
    1.83 +    FORCE )
    1.84 +SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    1.85 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.86 +    "Flags used by the shared libraries linker during maintainer builds."
    1.87 +    FORCE )
    1.88 +MARK_AS_ADVANCED(
    1.89 +    CMAKE_CXX_FLAGS_MAINTAINER
    1.90 +    CMAKE_C_FLAGS_MAINTAINER
    1.91 +    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.92 +    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
    1.93 +
    1.94 +IF(CMAKE_CONFIGURATION_TYPES)
    1.95 +  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
    1.96 +  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
    1.97 +  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    1.98 +      "Add the configurations that we need"
    1.99 +      FORCE)
   1.100 + endif()
   1.101 +
   1.102 +IF(NOT CMAKE_BUILD_TYPE)
   1.103 +  SET(CMAKE_BUILD_TYPE "Release")
   1.104 +ENDIF()
   1.105 +
   1.106 +SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
   1.107 +    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
   1.108 +    FORCE )
   1.109 +
   1.110 +
   1.111  INCLUDE(CheckTypeSize)
   1.112  CHECK_TYPE_SIZE("long long" LONG_LONG)
   1.113  SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
   1.114  
   1.115  ENABLE_TESTING()
   1.116  
   1.117 +IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
   1.118 +  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
   1.119 +ELSE()
   1.120 +  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
   1.121 +ENDIF()
   1.122 +
   1.123  ADD_SUBDIRECTORY(lemon)
   1.124  IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   1.125    ADD_SUBDIRECTORY(demo)
   1.126 @@ -62,7 +147,7 @@
   1.127    )
   1.128  ENDIF()
   1.129  
   1.130 -IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} AND WIN32)
   1.131 +IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   1.132    SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
   1.133    SET(CPACK_PACKAGE_VENDOR "EGRES")
   1.134    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
     2.1 --- a/doc/CMakeLists.txt	Sat Oct 10 08:19:26 2009 +0200
     2.2 +++ b/doc/CMakeLists.txt	Wed Aug 25 21:34:58 2010 +0200
     2.3 @@ -3,6 +3,8 @@
     2.4  SET(abs_top_srcdir ${PROJECT_SOURCE_DIR})
     2.5  SET(abs_top_builddir ${PROJECT_BINARY_DIR})
     2.6  
     2.7 +SET(LEMON_DOC_SOURCE_BROWSER "NO" CACHE STRING "Include source into the doc (YES/NO).")
     2.8 +
     2.9  CONFIGURE_FILE(
    2.10    ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
    2.11    ${PROJECT_BINARY_DIR}/doc/Doxyfile
    2.12 @@ -49,3 +51,15 @@
    2.13    ENDIF()
    2.14  
    2.15  ENDIF()
    2.16 +
    2.17 +IF(WGET_FOUND)
    2.18 +ADD_CUSTOM_TARGET(update-external-tags
    2.19 +  COMMAND ${CMAKE_COMMAND} -E make_directory dl
    2.20 +  # COMMAND ${CMAKE_COMMAND} -E copy libstdc++.tag dl
    2.21 +  COMMAND ${WGET_EXECUTABLE} wget -P dl -N libstdc++.tag.tmp http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
    2.22 +  COMMAND ${CMAKE_COMMAND} -E rename dl/libstdc++.tag libstdc++.tag
    2.23 +  COMMAND ${CMAKE_COMMAND} -E remove dl/libstdc++.tag
    2.24 +  COMMAND ${CMAKE_COMMAND} -E remove_directory dl
    2.25 +  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    2.26 +  )
    2.27 +ENDIF()
     3.1 --- a/doc/Doxyfile.in	Sat Oct 10 08:19:26 2009 +0200
     3.2 +++ b/doc/Doxyfile.in	Wed Aug 25 21:34:58 2010 +0200
     3.3 @@ -70,7 +70,7 @@
     3.4  SHOW_FILES             = YES
     3.5  SHOW_NAMESPACES        = YES
     3.6  FILE_VERSION_FILTER    = 
     3.7 -LAYOUT_FILE            = DoxygenLayout.xml
     3.8 +LAYOUT_FILE            = "@abs_top_srcdir@/doc/DoxygenLayout.xml"
     3.9  #---------------------------------------------------------------------------
    3.10  # configuration options related to warning and progress messages
    3.11  #---------------------------------------------------------------------------
    3.12 @@ -113,7 +113,7 @@
    3.13  #---------------------------------------------------------------------------
    3.14  # configuration options related to source browsing
    3.15  #---------------------------------------------------------------------------
    3.16 -SOURCE_BROWSER         = NO
    3.17 +SOURCE_BROWSER         = @LEMON_DOC_SOURCE_BROWSER@
    3.18  INLINE_SOURCES         = NO
    3.19  STRIP_CODE_COMMENTS    = YES
    3.20  REFERENCED_BY_RELATION = NO
    3.21 @@ -224,7 +224,7 @@
    3.22  #---------------------------------------------------------------------------
    3.23  # Options related to the search engine   
    3.24  #---------------------------------------------------------------------------
    3.25 -TAGFILES               = "@abs_top_srcdir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/  "
    3.26 +TAGFILES               = "@abs_top_builddir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/  "
    3.27  GENERATE_TAGFILE       = html/lemon.tag
    3.28  ALLEXTERNALS           = NO
    3.29  EXTERNAL_GROUPS        = NO
     4.1 --- a/lemon/CMakeLists.txt	Sat Oct 10 08:19:26 2009 +0200
     4.2 +++ b/lemon/CMakeLists.txt	Wed Aug 25 21:34:58 2010 +0200
     4.3 @@ -8,6 +8,12 @@
     4.4    ${CMAKE_CURRENT_BINARY_DIR}/config.h
     4.5  )
     4.6  
     4.7 +CONFIGURE_FILE(
     4.8 +  ${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.cmake
     4.9 +  ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
    4.10 +  @ONLY
    4.11 +)
    4.12 +
    4.13  SET(LEMON_SOURCES
    4.14    arg_parser.cc
    4.15    base.cc
    4.16 @@ -66,3 +72,9 @@
    4.17    DESTINATION include/lemon
    4.18    COMPONENT headers
    4.19  )
    4.20 +
    4.21 +INSTALL(
    4.22 +  FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
    4.23 +  DESTINATION lib/pkgconfig
    4.24 +)
    4.25 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/lemon/lemon.pc.cmake	Wed Aug 25 21:34:58 2010 +0200
     5.3 @@ -0,0 +1,10 @@
     5.4 +prefix=@CMAKE_INSTALL_PREFIX@
     5.5 +exec_prefix=@CMAKE_INSTALL_PREFIX@/bin
     5.6 +libdir=@CMAKE_INSTALL_PREFIX@/lib
     5.7 +includedir=@CMAKE_INSTALL_PREFIX@/include
     5.8 +
     5.9 +Name: @PROJECT_NAME@
    5.10 +Description: Library for Efficient Modeling and Optimization in Networks
    5.11 +Version: @PROJECT_VERSION@
    5.12 +Libs: -L${libdir} -lemon @GLPK_LIBS@ @CPLEX_LIBS@ @SOPLEX_LIBS@ @CLP_LIBS@ @CBC_LIBS@
    5.13 +Cflags: -I${includedir}
     6.1 --- a/test/CMakeLists.txt	Sat Oct 10 08:19:26 2009 +0200
     6.2 +++ b/test/CMakeLists.txt	Wed Aug 25 21:34:58 2010 +0200
     6.3 @@ -41,7 +41,12 @@
     6.4  )
     6.5  
     6.6  IF(LEMON_HAVE_LP)
     6.7 -  ADD_EXECUTABLE(lp_test lp_test.cc)
     6.8 +  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     6.9 +    ADD_EXECUTABLE(lp_test lp_test.cc)
    6.10 +  ELSE()
    6.11 +    ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc)
    6.12 +  ENDIF()
    6.13 +
    6.14    SET(LP_TEST_LIBS lemon)
    6.15  
    6.16    IF(LEMON_HAVE_GLPK)
    6.17 @@ -77,7 +82,12 @@
    6.18  ENDIF()
    6.19  
    6.20  IF(LEMON_HAVE_MIP)
    6.21 -  ADD_EXECUTABLE(mip_test mip_test.cc)
    6.22 +  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    6.23 +    ADD_EXECUTABLE(mip_test mip_test.cc)
    6.24 +  ELSE()
    6.25 +    ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc)
    6.26 +  ENDIF()
    6.27 +
    6.28    SET(MIP_TEST_LIBS lemon)
    6.29  
    6.30    IF(LEMON_HAVE_GLPK)
    6.31 @@ -113,7 +123,12 @@
    6.32  ENDIF()
    6.33  
    6.34  FOREACH(TEST_NAME ${TESTS})
    6.35 -  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
    6.36 +  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    6.37 +    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
    6.38 +  ELSE()
    6.39 +    ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
    6.40 +  ENDIF()
    6.41    TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
    6.42    ADD_TEST(${TEST_NAME} ${TEST_NAME})
    6.43 +  ADD_DEPENDENCIES(check ${TEST_NAME})
    6.44  ENDFOREACH()