You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.4 KiB
92 lines
3.4 KiB
cmake_minimum_required(VERSION 2.8.5) |
|
|
|
# Make sure the user doesn't play dirty with symlinks |
|
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) |
|
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) |
|
|
|
# Disallow in-source builds |
|
if(${srcdir} STREQUAL ${bindir}) |
|
message(FATAL_ERROR "In-source builds are not allowed." |
|
" Please create a directory and run cmake from there, passing the path" |
|
" to this source directory as the last argument. This process created" |
|
" the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}." |
|
" Please remove them.") |
|
endif() |
|
|
|
project(gmt_makemap CXX) |
|
|
|
if(NOT CMAKE_BUILD_TYPE) |
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE) |
|
endif() |
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" CACHE INTERNAL "Location of our custom CMake modules." FORCE) |
|
|
|
include_directories(include) |
|
|
|
# Checking compiler options |
|
set(default_options -Wall) |
|
include(CheckCXXCompilerFlag) |
|
# C++11 is required |
|
CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11) |
|
CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X) |
|
if(COMPILER_SUPPORTS_CXX11) |
|
set(default_options ${default_options} -std=c++11) |
|
elseif(COMPILER_SUPPORTS_CXX0X) |
|
set(default_options ${default_options} -std=c++0x) |
|
else() |
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") |
|
endif() |
|
# Link time optimization check |
|
CHECK_CXX_COMPILER_FLAG(-flto COMPILER_SUPPORTS_FLTO) |
|
if(COMPILER_SUPPORTS_FLTO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
set(default_options ${default_options} -flto) |
|
endif() |
|
# -ipo flag check (Intel compiler link time optimization) |
|
CHECK_CXX_COMPILER_FLAG(-ipo COMPILER_SUPPORTS_IPO) |
|
if(COMPILER_SUPPORTS_IPO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
set(default_options ${default_options} -ipo) |
|
endif() |
|
# Default hidden visibility check |
|
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden COMPILER_SUPPORTS_HIDDEN) |
|
if(COMPILER_SUPPORTS_HIDDEN) |
|
set(default_options ${default_options} -fvisibility=hidden) |
|
endif() |
|
# Export dynamic. Required as modules mast call functions from main programm |
|
CHECK_CXX_COMPILER_FLAG(-Wl,--export-dynamic COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
if(COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
set(default_options ${default_options} -Wl,--export-dynamic) |
|
else() |
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no support of --export-dynamic. Please use a different C++ compiler.") |
|
endif() |
|
add_compile_options(${default_options}) |
|
|
|
file(GLOB modules modules/*) |
|
file(GLOB extramodules extramodules/*) |
|
|
|
set(STATIC_MODULES "") |
|
|
|
foreach(ext ${modules}) |
|
if(EXISTS ${ext}/CMakeLists.txt) |
|
string(REGEX REPLACE .*/ "" modname ${ext}) |
|
option(MODULE_${modname}_BUILD "Build module ${modname}" ON) |
|
option(MODULE_${modname}_STATIC "Link module ${modname} statically in gmt_makemap" ON) |
|
mark_as_advanced(FORCE MODULE_${modname}_STATIC) |
|
if(MODULE_${modname}_BUILD) |
|
add_subdirectory(modules/${modname}) |
|
endif() |
|
endif() |
|
endforeach(ext) |
|
|
|
foreach(ext ${extramodules}) |
|
if(EXISTS ${ext}/CMakeLists.txt) |
|
string(REGEX REPLACE .*/ "" modname ${ext}) |
|
option(MODULE_${modname}_BUILD "Build module ${modname}" ON) |
|
option(MODULE_${modname}_STATIC "Link module ${modname} statically in gmt_makemap" ON) |
|
mark_as_advanced(FORCE MODULE_${modname}_STATIC) |
|
if(MODULE_${modname}_BUILD) |
|
add_subdirectory(extramodules/${modname}) |
|
endif() |
|
endif() |
|
endforeach(ext) |
|
|
|
add_subdirectory(src)
|
|
|