|
38 | 38 | # This file contains the top level CMakeLists.txt logic for the |
39 | 39 | # SCL software package. |
40 | 40 |
|
| 41 | +PROJECT(SCL) |
| 42 | +SET(SCL_VERSION_MAJOR 0) |
| 43 | +SET(SCL_VERSION_MINOR 5-dev) |
| 44 | +SET(SCL_VERSION ${SCL_VERSION_MAJOR}.${SCL_VERSION_MINOR}) |
| 45 | + |
41 | 46 | # Minimum required version of CMake |
42 | 47 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8) |
43 | 48 | IF(COMMAND CMAKE_POLICY) |
44 | 49 | CMAKE_POLICY(SET CMP0003 NEW) |
45 | 50 | ENDIF(COMMAND CMAKE_POLICY) |
46 | 51 |
|
47 | | -# set CMake project name |
48 | | -PROJECT(SCL) |
49 | | - |
50 | | -if( CMAKE_BUILD_TYPE STREQUAL "" ) |
51 | | - message( "-- Debug build - to override, rerun cmake with '-DCMAKE_BUILD_TYPE=Release'." ) |
52 | | - set( CMAKE_BUILD_TYPE Debug ) |
53 | | -endif() |
| 52 | +IF (NOT MSVC) |
| 53 | + IF( NOT DEFINED SCL_BUILD_TYPE ) |
| 54 | + SET( SCL_BUILD_TYPE "Debug" CACHE STRING "Build type" ) # By default set debug build |
| 55 | + ENDIF( NOT DEFINED SCL_BUILD_TYPE ) |
| 56 | + SET( CMAKE_BUILD_TYPE ${SCL_BUILD_TYPE} CACHE INTERNAL "Build type, |
| 57 | + immutable" FORCE ) |
| 58 | +ENDIF(NOT MSVC) |
| 59 | + |
| 60 | +# Define helper macro OPTION_WITH_DEFAULT |
| 61 | +MACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT ) |
| 62 | + IF( NOT DEFINED ${OPTION_NAME} ) |
| 63 | + SET( ${OPTION_NAME} ${OPTION_DEFAULT} ) |
| 64 | + ENDIF( NOT DEFINED ${OPTION_NAME} ) |
| 65 | + OPTION( ${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}} ) |
| 66 | +ENDMACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT ) |
54 | 67 |
|
55 | 68 | # build shared libs by default |
56 | | -OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) |
| 69 | +OPTION_WITH_DEFAULT(SCL_BUILD_SHARED_LIBS "Build shared libs" ON ) |
57 | 70 |
|
58 | 71 | # build static libs by default |
59 | | -OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF) |
| 72 | +OPTION_WITH_DEFAULT(SCL_BUILD_STATIC_LIBS "Build static libs" OFF) |
60 | 73 |
|
61 | | -OPTION(PYTHON_GENERATOR "Compile fedex_plus_python" ON) |
62 | | -OPTION(CPP_GENERATOR "Compile fedex_plus" ON) |
63 | | - |
64 | | -# Set version |
65 | | -SET(SCL_VERSION_MAJOR "3") |
66 | | -SET(SCL_VERSION_MINOR "2") |
67 | | -SET(SCL_VERSION_PATCH "0") |
68 | | -SET(SCL_VERSION "${SCL_VERSION_MAJOR}.${SCL_VERSION_MINOR}.${SCL_VERSION_PATCH}") |
| 74 | +OPTION_WITH_DEFAULT(SCL_PYTHON_GENERATOR "Compile fedex_plus_python" ON) |
| 75 | +OPTION_WITH_DEFAULT(SCL_CPP_GENERATOR "Compile fedex_plus" ON) |
69 | 76 |
|
70 | 77 | # CMake derives much of its functionality from modules, typically |
71 | 78 | # stored in one directory - let CMake know where to find them. |
@@ -100,16 +107,28 @@ ENDIF(NOT WIN32) |
100 | 107 |
|
101 | 108 | #--------------------------------------------------------------------- |
102 | 109 | # Testing option |
103 | | -OPTION( ENABLE_TESTING "Enable unittesting framework" OFF ) |
104 | | -IF(ENABLE_TESTING) |
105 | | - set( CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage" ) #for code coverage |
106 | | - set( CMAKE_SHARED_LINKER_FLAGS "-fprofile-arcs -ftest-coverage" ) |
107 | | - if( NOT DEFINED BUILD_SCHEMAS ) |
108 | | - set( BUILD_SCHEMAS "ALL" ) #test all schemas, unless otherwise specified |
| 110 | +OPTION_WITH_DEFAULT( SCL_ENABLE_TESTING "Enable unittesting framework" ON ) |
| 111 | +IF(SCL_ENABLE_TESTING) |
| 112 | + if( NOT DEFINED SCL_BUILD_SCHEMAS ) |
| 113 | + set( SCL_BUILD_SCHEMAS "ALL" ) #test all schemas, unless otherwise specified |
109 | 114 | endif() |
110 | 115 | INCLUDE(CTest) |
111 | 116 | ENABLE_TESTING() |
112 | | -ENDIF(ENABLE_TESTING) |
| 117 | +ENDIF(SCL_ENABLE_TESTING) |
| 118 | + |
| 119 | +#--------------------------------------------------------------------- |
| 120 | +# Coverage option |
| 121 | +OPTION_WITH_DEFAULT( SCL_ENABLE_COVERAGE "Enable code coverage test" OFF ) |
| 122 | +IF(SCL_ENABLE_COVERAGE) |
| 123 | + SET(SCL_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE) |
| 124 | + # build static libs, better coverage report |
| 125 | + SET(SCL_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE ) |
| 126 | + SET(SCL_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE ) |
| 127 | + SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) |
| 128 | + SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) |
| 129 | + SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE) |
| 130 | + SET(SCL_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE) |
| 131 | +ENDIF(SCL_ENABLE_COVERAGE) |
113 | 132 |
|
114 | 133 | #--------------------------------------------------------------------- |
115 | 134 | # The following logic is what allows binaries to run successfully in |
@@ -174,23 +193,21 @@ ENDFOREACH() |
174 | 193 | # The location in which to install SCL. Need a good Debug location |
175 | 194 | # for Windows. Only do this if CMAKE_INSTALL_PREFIX hasn't been set |
176 | 195 | # already, to try and allow parent builds (if any) some control. |
177 | | -IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
178 | | - IF(NOT WIN32) |
179 | | - IF ("${CMAKE_BUILD_TYPE}" MATCHES "Release") |
180 | | - SET(CMAKE_INSTALL_PREFIX "/usr") |
181 | | - ELSEIF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug") |
182 | | - SET(CMAKE_INSTALL_PREFIX "${SCL_SOURCE_DIR}/../scl-install") |
183 | | - MESSAGE("--- Setting debug install dir to ${CMAKE_INSTALL_PREFIX}") |
184 | | - ELSE("${CMAKE_BUILD_TYPE}" MATCHES "Release") |
185 | | - SET(CMAKE_INSTALL_PREFIX "/usr/local") |
186 | | - ENDIF ("${CMAKE_BUILD_TYPE}" MATCHES "Release") |
187 | | - ENDIF(NOT WIN32) |
188 | | - SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "SCL install prefix" FORCE) |
189 | | - SET(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0) |
190 | | -ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
191 | | - |
192 | | -OPTION(SCL-BUILD_EXPRESS_ONLY "Only build express parser." OFF) |
193 | | -MARK_AS_ADVANCED(SCL-BUILD_EXPRESS_ONLY) |
| 196 | +IF(NOT WIN32) |
| 197 | + IF (${CMAKE_BUILD_TYPE} MATCHES "Debug") |
| 198 | + SET(SCL_INSTALL_PREFIX "${SCL_SOURCE_DIR}/../scl-install") |
| 199 | + ELSE() |
| 200 | + SET(SCL_INSTALL_PREFIX "/usr/local") |
| 201 | + ENDIF() |
| 202 | +ENDIF(NOT WIN32) |
| 203 | +SET( SCL_INSTALL_PREFIX ${SCL_INSTALL_PREFIX} CACHE |
| 204 | + PATH "Install prefix prepended to target to create install location" ) |
| 205 | +SET( CMAKE_INSTALL_PREFIX ${SCL_INSTALL_PREFIX} CACHE INTERNAL "Prefix |
| 206 | + prepended to install directories if target destination is not absolute, |
| 207 | + immutable" FORCE ) |
| 208 | + |
| 209 | +OPTION(SCL_BUILD_EXPRESS_ONLY "Only build express parser." OFF) |
| 210 | +MARK_AS_ADVANCED(SCL_BUILD_EXPRESS_ONLY) |
194 | 211 |
|
195 | 212 | # Take the scl config file template and copy it to the build directory so CMake |
196 | 213 | # scripts can append to it if need be |
@@ -277,3 +294,31 @@ ADD_SUBDIRECTORY(doc) |
277 | 294 | # this is for testing - 'make core' builds everything that isn't generated |
278 | 295 | add_custom_target( core ) |
279 | 296 | add_dependencies( core stepdai check-express stepeditor fedex_plus ) |
| 297 | + |
| 298 | +############################################################################### |
| 299 | +# SCL Packaging # |
| 300 | +# $make package # |
| 301 | +############################################################################### |
| 302 | + |
| 303 | +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEP Class Library") |
| 304 | +SET(CPACK_SET_DESTDIR "ON") |
| 305 | + |
| 306 | +SET(CPACK_PACKAGE_VERSION_MAJOR ${SCL_VERSION_MAJOR}) |
| 307 | +SET(CPACK_PACKAGE_VERSION_MINOR ${SCL_VERSION_MINOR}) |
| 308 | +SET(CPACK_PACKAGE_NAME SCL ) |
| 309 | + |
| 310 | +SET(CPACK_PACKAGE_CONTACT "SCL Developers <scl-dev@googlegroups.com>") |
| 311 | +INCLUDE(CPack) |
| 312 | + |
| 313 | +######################################################################################## |
| 314 | +# Uninstall code # |
| 315 | +# From http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F # |
| 316 | +# ###################################################################################### |
| 317 | +configure_file( |
| 318 | + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" |
| 319 | + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
| 320 | + IMMEDIATE @ONLY) |
| 321 | + |
| 322 | +add_custom_target(uninstall |
| 323 | + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) |
| 324 | + |
0 commit comments