Select Git revision
CMakeLists.txt
CMakeLists.txt 13.08 KiB
# CMAKE_MSVC_RUNTIME_LIBRARY requires 3.15
cmake_minimum_required(VERSION 3.20)
project (
IPhreeqc
VERSION 3.6.3
LANGUAGES CXX C
)
# check if this is the root project
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(STANDALONE_BUILD 1)
else()
set(STANDALONE_BUILD 0)
endif()
if (STANDALONE_BUILD)
# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
endif()
# overide docdir on windows
if (WIN32 AND NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (doc)")
set(CMAKE_INSTALL_DOCDIR "doc")
endif()
# set standard directory locations
include(GNUInstallDirs)
if (STANDALONE_BUILD AND MSVC)
option (IPHREEQC_STATIC_RUNTIME "Build with a static runtime" OFF)
if (IPHREEQC_STATIC_RUNTIME)
# compile with static runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
# Fortran
option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON)
if (STANDALONE_BUILD)
if (IPHREEQC_FORTRAN_TESTING)
enable_language(Fortran)
else()
if (CMAKE_Fortran_COMPILER)
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" ON)
else()
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" OFF)
endif()
endif()
endif()
# compile Var.c as c++
set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX)
if (STANDALONE_BUILD)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
set(LIB_TYPE STATIC)
endif()
if (STANDALONE_BUILD)
if (MSVC)
option(BUILD_CLR_LIBS "Build CLR Libraries" OFF)