# HG changeset patch # User Alpar Juttner # Date 2010-09-10 12:04:38 # Node ID 63e4468c680edea1dfd31718b58fe4e0487f1ef5 # Parent 659ba4805a48df7caed64a21861195c5b79ce1d5 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 diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,10 +72,42 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}") +SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb" CACHE STRING + "Flags used by the C++ compiler during maintainer builds." + FORCE ) +SET( CMAKE_C_FLAGS_MAINTAINER "-Werror" CACHE STRING + "Flags used by the C compiler during maintainer builds." + FORCE ) +SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER + "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING + "Flags used for linking binaries during maintainer builds." + FORCE ) +SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER + "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING + "Flags used by the shared libraries linker during maintainer builds." + FORCE ) +MARK_AS_ADVANCED( + CMAKE_CXX_FLAGS_MAINTAINER + CMAKE_C_FLAGS_MAINTAINER + CMAKE_EXE_LINKER_FLAGS_MAINTAINER + CMAKE_SHARED_LINKER_FLAGS_MAINTAINER ) + +IF(CMAKE_CONFIGURATION_TYPES) + LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer) + LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES) + SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING + "Add the configurations that we need" + FORCE) + endif() + IF(NOT CMAKE_BUILD_TYPE) - 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) + SET(CMAKE_BUILD_TYPE "Release") ENDIF() +SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING + "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer." + FORCE ) + INCLUDE(CheckTypeSize) CHECK_TYPE_SIZE("long long" LONG_LONG) @@ -83,7 +115,11 @@ ENABLE_TESTING() -ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) +IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") + ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND}) +ELSE() + ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) +ENDIF() ADD_SUBDIRECTORY(lemon) IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -117,7 +117,11 @@ ENDIF() FOREACH(TEST_NAME ${TESTS}) - ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc) + IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") + ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) + ELSE() + ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc) + ENDIF() TARGET_LINK_LIBRARIES(${TEST_NAME} lemon) ADD_TEST(${TEST_NAME} ${TEST_NAME}) ADD_DEPENDENCIES(check ${TEST_NAME})