|
|
|
cmake_minimum_required(VERSION 3.9)
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
|
|
|
set(STATIC_ANALYZER OFF CACHE BOOL "Using GCC static analyzer if available")
|
|
|
|
|
|
|
|
project(odm C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
|
|
|
|
|
|
|
include_directories(include GSW-C)
|
|
|
|
add_compile_options(-Wall)
|
|
|
|
|
|
|
|
# Dwarf-4 support check
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
CHECK_CXX_COMPILER_FLAG(-gdwarf-4 COMPILER_SUPPORTS_DWARF4)
|
|
|
|
if(COMPILER_SUPPORTS_DWARF4 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
|
|
|
|
add_compile_options(-gdwarf-4)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# GCC static analyzer support check
|
|
|
|
CHECK_CXX_COMPILER_FLAG(-fanalyzer COMPILER_SUPPORTS_ANALYZER)
|
|
|
|
if(COMPILER_SUPPORTS_ANALYZER AND STATIC_ANALYZER)
|
|
|
|
add_compile_options(-fanalyzer)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(teos STATIC GSW-C/gsw_oceanographic_toolbox.c GSW-C/gsw_saar.c)
|
|
|
|
set_target_properties(teos PROPERTIES LINKER_LANGUAGE C)
|
|
|
|
|
|
|
|
add_subdirectory(src)
|