forked from themoos/core-moos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
205 lines (153 loc) · 6.96 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
###########################################################
# Top level CMakeLists.txt file for the core-moos Project
###########################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
set(PROJECTNAME MOOS)
set(PACKAGE_VERSION_MAJOR 10)
set(PACKAGE_VERSION_MINOR 0)
set(PACKAGE_VERSION_PATCH 3)
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
message(STATUS "+++ This MOOS version ${PACKAGE_VERSION} +++")
# If user specifies the build type, use theirs, otherwise use release
if (NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
endif()
project(${PROJECTNAME})
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
endif()
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
endif()
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
endif()
set(CMakeScripts_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMakeScripts_MODULE_DIR})
# Look at system to see what if any options are available because
# of build environment
include(SystemDefines)
# Turn on all compiler warnings
include(EnableAllWarnings)
# Bring in helper functions for dealing with CACHE INTERNAL variables
include(CacheInternalHelpers)
#figure out our git version
option(UPDATE_GIT_VERSION_INFO "update git version info in source tree" ON)
mark_as_advanced(UPDATE_GIT_VERSION_INFO)
if(UPDATE_GIT_VERSION_INFO)
include(GitInfo)
endif()
# We want to create dynamic libraries
set(BUILD_SHARED_LIBS true)
# Enable Doxygen build with 'make doxygen'
option(ENABLE_DOXYGEN "Enable a 'make doc' target for Doxygen documentation")
if (ENABLE_DOXYGEN)
include(UseDoxygen)
endif()
# Enable CDash testing
option(CDASH_SUPPORT "Turn on testing targets that upload results to CDash" OFF)
if( CDASH_SUPPORT )
include(SystemUtilityFunctions)
moos_make_informative_build_name(CTEST_BUILD_NAME)
# BUILDNAME is what is required for CTest
set(BUILDNAME ${CTEST_BUILD_NAME})
enable_testing()
include( CTest )
endif()
# Option for code coverage
option(CODE_COVERAGE "Build code coverage results, requires GCC compiler (forces Debug build)" OFF)
if(CODE_COVERAGE)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
# Ensure that CDash targets are always enabled if coverage is enabled.
if (NOT CDASH_SUPPORT)
get_property(HELP_STRING CACHE CDASH_SUPPORT PROPERTY HELPSTRING)
set(CDASH_SUPPORT ON CACHE BOOL "${HELP_STRING}" FORCE)
message(STATUS "Enabling CDash targets as coverage has been enabled.")
endif()
endif(CMAKE_COMPILER_IS_GNUCXX)
endif()
# Option for explicitly linking against the GNU libstdc++ instead of libc++ on
# OSX Mavericks, required in order to use iMatlab as MATLAB still uses libstdc++
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# On OSX, get the version number.
find_program(SW_VERS_PROGRAM sw_vers)
mark_as_advanced(SW_VERS_PROGRAM)
execute_process(COMMAND ${SW_VERS_PROGRAM} "-productVersion"
OUTPUT_VARIABLE OSX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Mavericks (10.9) and above use libc++ as the default.
set(OSX_MAVERICKS_VERSION 10.9)
if (OSX_VERSION VERSION_EQUAL OSX_MAVERICKS_VERSION OR
OSX_VERSION VERSION_GREATER OSX_MAVERICKS_VERSION)
option(USE_LIBSTDCPP
"Use (legacy) GNU libstdc++ on OSX >= ${OSX_MAVERICKS_VERSION}, instead of default LLVM libc++ (required for iMatlab)" OFF)
if (USE_LIBSTDCPP)
message("Running OS X Mavericks (specific version: ${OSX_VERSION}) using "
"legacy GNU libstdc++ instead of default LLVM libc++, disable "
"USE_LIBSTDCPP option to revert to default LLVM libc++.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
else()
# Remove any previous specification of libstdc++.
message(STATUS "Using default LLVM libc++.")
string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
endif()
endif()
########### SETTING UP PREPROCESSOR ################
include(PlatformDefines)
#####################################################
# Toby Schneider's request for fPIC on amd64
IF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
ENDIF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
add_subdirectory(Core)
#########################
# Config Script Creation
#########################
# Add your library's name to PROJECT_EXPORT_LIBS if you wish to have it exported
# (This is a CACHE INTERNAL variable)
option(ENABLE_EXPORT "do you want CMake to record this build so other projects can find it " ON)
if(ENABLE_EXPORT)
message(STATUS "location of this build will be exported, set ENABLE_EXPORT to OFF if you don't want this and delete ~/.cmake/projects/MOOS ")
endif()
if(1)
if (PROJECT_EXPORT_LIBS)
message(STATUS "PROJECT_EXPORT_LIBS = ${PROJECT_EXPORT_LIBS}")
# Provide a cmake config script for the build directory
export(TARGETS
${PROJECT_EXPORT_LIBS}
FILE
Use${PROJECTNAME}.cmake
)
set(CONFIG_FILE "${PROJECT_BINARY_DIR}/${PROJECTNAME}Config.cmake")
configure_file( "cmake/ProjectConfig.cmake.in" ${CONFIG_FILE} @ONLY )
# Append libary specific lines to the generated config script
foreach(EXPORT_LIB ${PROJECT_EXPORT_LIBS})
file(APPEND ${CONFIG_FILE} "\n# Export variables for ${EXPORT_LIB} Library\n")
file(APPEND ${CONFIG_FILE} "set(${EXPORT_LIB}_LIBRARIES \"${${EXPORT_LIB}_LIBRARIES}\")\n")
file(APPEND ${CONFIG_FILE} "set(${EXPORT_LIB}_INCLUDE_DIRS \"${${EXPORT_LIB}_INCLUDE_DIRS}\")\n")
file(APPEND ${CONFIG_FILE} "set(${EXPORT_LIB}_DEPEND_LIBRARIES \"${${EXPORT_LIB}_DEPEND_LIBRARIES}\")\n")
file(APPEND ${CONFIG_FILE} "set(${EXPORT_LIB}_DEPEND_INCLUDE_DIRS \"${${EXPORT_LIB}_DEPEND_INCLUDE_DIRS}\")\n")
endforeach()
foreach(DEFINE ${PROJECT_EXPORT_DEFINES})
file(APPEND ${CONFIG_FILE} "ADD_DEFINITIONS(-D${DEFINE})\n")
#file(APPEND ${CONFIG_FILE} "message(STATUS \"adding -D${DEFINE} as required my MOOS\")\n" )
endforeach()
endif()
if(ENABLE_EXPORT)
# Stick build location in the central CMake user package registry, so that it may be easily found
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.7)
export(PACKAGE ${PROJECTNAME})
endif()
endif()
endif()
#here we save a version file
set(VERSION_FILE "${PROJECT_BINARY_DIR}/${PROJECTNAME}ConfigVersion.cmake")
configure_file( "cmake/ProjectConfigVersion.cmake.in" ${VERSION_FILE} @ONLY )