CMakeLists.txt
branch1.1
changeset 743 653259678d43
parent 682 257e91516e09
child 749 64260c0f58eb
     1.1 --- a/CMakeLists.txt	Mon Feb 28 09:50:33 2011 +0100
     1.2 +++ b/CMakeLists.txt	Fri Mar 04 10:40:19 2011 +0100
     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