Skip to content
Snippets Groups Projects
Select Git revision
  • 1a8e4166dcb5c84cf8f2c37d3b5dec6a1af0b85f
  • poet default protected
  • ml/selected-output
  • golem_subs
  • ml/project-name
  • 7-check-phreeqcmatrix-subset-or-removenan
  • 2-refactor-cmake-installation-workflow
  • v0.3
  • v0.2
  • v0.1
10 results

CMakeLists.txt

Blame
  • 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)