Add 'Maintainer' CMAKE build type (#388, #390)
authorAlpar Juttner <alpar@cs.elte.hu>
Fri, 10 Sep 2010 12:04:38 +0200
changeset 90163e4468c680e
parent 900 659ba4805a48
child 902 a725503acfe9
Add 'Maintainer' CMAKE build type (#388, #390)

- some extra warning and debug options
- build stops on warning (-Werror)
- tests are built and run by default
CMakeLists.txt
test/CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Thu Sep 09 15:55:00 2010 +0200
     1.2 +++ b/CMakeLists.txt	Fri Sep 10 12:04:38 2010 +0200
     1.3 @@ -72,10 +72,42 @@
     1.4  
     1.5  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
     1.6  
     1.7 +SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb" CACHE STRING
     1.8 +    "Flags used by the C++ compiler during maintainer builds."
     1.9 +    FORCE )
    1.10 +SET( CMAKE_C_FLAGS_MAINTAINER "-Werror" CACHE STRING
    1.11 +    "Flags used by the C compiler during maintainer builds."
    1.12 +    FORCE )
    1.13 +SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.14 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.15 +    "Flags used for linking binaries during maintainer builds."
    1.16 +    FORCE )
    1.17 +SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    1.18 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.19 +    "Flags used by the shared libraries linker during maintainer builds."
    1.20 +    FORCE )
    1.21 +MARK_AS_ADVANCED(
    1.22 +    CMAKE_CXX_FLAGS_MAINTAINER
    1.23 +    CMAKE_C_FLAGS_MAINTAINER
    1.24 +    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.25 +    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
    1.26 +
    1.27 +IF(CMAKE_CONFIGURATION_TYPES)
    1.28 +  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
    1.29 +  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
    1.30 +  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    1.31 +      "Add the configurations that we need"
    1.32 +      FORCE)
    1.33 + endif()
    1.34 +
    1.35  IF(NOT CMAKE_BUILD_TYPE)
    1.36 -  SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
    1.37 +  SET(CMAKE_BUILD_TYPE "Release")
    1.38  ENDIF()
    1.39  
    1.40 +SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
    1.41 +    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
    1.42 +    FORCE )
    1.43 +
    1.44  
    1.45  INCLUDE(CheckTypeSize)
    1.46  CHECK_TYPE_SIZE("long long" LONG_LONG)
    1.47 @@ -83,7 +115,11 @@
    1.48  
    1.49  ENABLE_TESTING()
    1.50  
    1.51 -ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
    1.52 +IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    1.53 +  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
    1.54 +ELSE()
    1.55 +  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
    1.56 +ENDIF()
    1.57  
    1.58  ADD_SUBDIRECTORY(lemon)
    1.59  IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
     2.1 --- a/test/CMakeLists.txt	Thu Sep 09 15:55:00 2010 +0200
     2.2 +++ b/test/CMakeLists.txt	Fri Sep 10 12:04:38 2010 +0200
     2.3 @@ -117,7 +117,11 @@
     2.4  ENDIF()
     2.5  
     2.6  FOREACH(TEST_NAME ${TESTS})
     2.7 -  ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
     2.8 +  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     2.9 +    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
    2.10 +  ELSE()
    2.11 +    ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
    2.12 +  ENDIF()
    2.13    TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
    2.14    ADD_TEST(${TEST_NAME} ${TEST_NAME})
    2.15    ADD_DEPENDENCIES(check ${TEST_NAME})