cmake_minimum_required(VERSION 3.8) project(CMake) # enable project files grouping by folders set_property(GLOBAL PROPERTY USE_FOLDERS ON) if (UNIX) message(STATUS "Configuring in unix") include(linux_scripts.cmake) add_definitions(-DCOMMIT_VERSION=${COMMIT_VERSION}) endif(UNIX) if (WIN32) message(STATUS "Configuring in windows") include(windows_scripts.cmake) endif(WIN32) include(functions.cmake) include(modules.cmake) # Check CMake optional arguments set(CONFIGURATION_TYPE "DFLOWFM" CACHE STRING "Sets the configuration to be generated by this script.") message(STATUS "build nr: ${COMMIT_VERSION}") # Set this to true to group all predefined projects set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Set compiler flags enable_language(Fortran C CXX) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") # To be implemented later on endif() if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") include(compiler_options/intel.cmake) endif() if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") # To be implemented later on endif() if (WIN32) message(STATUS "Setting compiler flags in windows") set(CMAKE_Fortran_FLAGS "/W1 /nologo /libs:dll /threads /MP") set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${debug_flags}") endif(WIN32) if (UNIX) message(STATUS "Setting compiler flags in unix") set(CMAKE_Fortran_FLAGS "${compiler_flags}") set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${compiler_flags}") endif(UNIX) # Set available build configurations for the .sln file set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) # Set checkout root set(checkout_src_root ${CMAKE_CURRENT_SOURCE_DIR}/..) # This points to the location of OSS/src # MPI set(OSS_MPI "IntelMPI" CACHE STRING "MPI library is IntelMPI") #set(OSS_MPI "MPICH" CACHE STRING "MPI library is MPICH") if (WIN32) # Set pthreads library set(pthreads_path ${checkout_src_root}/third_party_open/pthreads/include/x64) # Set mpi_include_path if ("${OSS_MPI}" STREQUAL "IntelMPI") set(mpi_include_path $ENV{I_MPI_ONEAPI_ROOT}/include) set(mpi_library_path $ENV{I_MPI_ONEAPI_ROOT}/lib/$;$ENV{I_MPI_ONEAPI_ROOT}/lib) set(mpi_fortran_library "impi.lib") set(mpi_c_library "impi.lib;impicxx.lib") else() set(mpi_include_path ${checkout_src_root}/third_party_open/mpich2/x64/include) set(mpi_library_path ${checkout_src_root}/third_party_open/mpich2/x64/lib) set(mpi_fortran_library "fmpich2.lib mpi.lib") set(mpi_c_library "mpi.lib") endif() # Set the Tecplot path set(tecplot_path ${checkout_src_root}/third_party_open/Tecplot/include) # Set the petsc path set(petsc_path ${checkout_src_root}/third_party_open/petsc/petsc-3.10.2/include) # Set the expat path set(expat_path ${checkout_src_root}/third_party_open/expat/x64/include) # Set the GDAL path set(gisinternals_path ${checkout_src_root}/third_party_open/GISInternals/release-1911-x64/lib) add_definitions(-DHAVE_MPI=1) endif() if (UNIX) #Packages find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) #MPI find_package(MPI REQUIRED) add_definitions(-DHAVE_MPI) #NetCDF pkg_check_modules(NETCDF REQUIRED IMPORTED_TARGET netcdf) pkg_check_modules(NETCDF_FTN REQUIRED IMPORTED_TARGET netcdf-fortran) # Petsc pkg_check_modules(PETSC REQUIRED PETSc) # Proj pkg_check_modules(PROJ REQUIRED proj) # Version number message(STATUS "Configuring and building the version number executable under unix") execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${checkout_src_root}/third_party_open/version_number/packages/version_number RESULT_VARIABLE result WORKING_DIRECTORY ${checkout_src_root}/third_party_open/version_number/packages/version_number/src ) if(result) message(FATAL_ERROR "CMake could not generate the version number executable") endif() execute_process(COMMAND ${CMAKE_COMMAND} --build ${checkout_src_root}/third_party_open/version_number/packages/version_number/src) endif(UNIX) # Set the location of the update_version script set(update_version_script_path ${checkout_src_root}/${update_version_script}) set(postbuild_event_path ${checkout_src_root}/${postbuild_event_script}) # Set root name of the projects in the root UI of Visual Studio set(visual_studio_source_group_name "Source Files") ### Configuration names string(TOUPPER ${CONFIGURATION_TYPE} configuration_type) # Basic (single-component) configurations set(dflowfm_configuration "DFLOWFM") set(dflowfm_interacter_configuration "DFLOWFM_INTERACTER") set(tests_configuration "TESTS") set(dimr_configuration "DIMR") set(dwaq_configuration "DWAQ") set(dwaves_configuration "DWAVES") set(swan_configuration "SWAN") set(flow2d3d_configuration "FLOW2D3D") set(tools_configuration "TOOLS") # Combined (multi-component) configurations set(delft3dfm_configuration "DELFT3DFM") set(delft3d4_configuration "DELFT3D4") set(all_configuration "ALL") # Determine the configuration to make if(NOT (${configuration_type} STREQUAL ${tests_configuration} OR ${configuration_type} STREQUAL ${dflowfm_configuration} OR ${configuration_type} STREQUAL ${dflowfm_interacter_configuration} OR ${configuration_type} STREQUAL ${dimr_configuration} OR ${configuration_type} STREQUAL ${dwaq_configuration} OR ${configuration_type} STREQUAL ${dwaves_configuration} OR ${configuration_type} STREQUAL ${swan_configuration} OR ${configuration_type} STREQUAL ${flow2d3d_configuration} OR ${configuration_type} STREQUAL ${tools_configuration} OR ${configuration_type} STREQUAL ${delft3dfm_configuration} OR ${configuration_type} STREQUAL ${delft3d4_configuration} OR ${configuration_type} STREQUAL ${all_configuration})) message(FATAL_ERROR "${configuration_type} not recognized. CMake will abort solution generation now.") endif() ### Basic configurations # Tests configuration if(${configuration_type} STREQUAL ${tests_configuration}) message(STATUS "Generating solution for Tests ...") include(configurations/tests_configuration.cmake) endif() # D-Flow FM configuration if(${configuration_type} STREQUAL ${dflowfm_configuration}) message(STATUS "Generating solution for D-Flow FM ...") include(configurations/dflowfm_configuration.cmake) endif() # D-Flow FM (with Interacter-GUI) configuration if(${configuration_type} STREQUAL ${dflowfm_interacter_configuration}) message(STATUS "Generating solution for D-Flow FM (with interacter) ...") include(configurations/dflowfm_interacter_configuration.cmake) endif() # DIMR configuration if(${configuration_type} STREQUAL ${dimr_configuration}) message(STATUS "Generating solution for DIMR ...") include(configurations/dimr_configuration.cmake) endif() # D-WAQ configuration if(${configuration_type} STREQUAL ${dwaq_configuration}) message(STATUS "Generating solution for D-Waq ...") include(configurations/dwaq_configuration.cmake) endif() # D-Waves configuration if(${configuration_type} STREQUAL ${dwaves_configuration}) message(STATUS "Generating solution for D-Waves ...") include(configurations/dwaves_configuration.cmake) endif() # SWAN configuration if(${configuration_type} STREQUAL ${swan_configuration}) message(STATUS "Generating solution for SWAN ...") include(configurations/swan_configuration.cmake) endif() # Flow2D3D (Delft3D4) configuration if(${configuration_type} STREQUAL ${flow2d3d_configuration}) message(STATUS "Generating solution for Flow2D3D ...") include(configurations/flow2d3d_configuration.cmake) endif() # Tools configuration if(${configuration_type} STREQUAL ${tools_configuration}) message(STATUS "Generating solution for Tools ...") include(configurations/tools_configuration.cmake) endif() ### Composed configurations # Delft3D-FM configuration (dimr, dflowfm, dwaq, dwaves, and some tools) if(${configuration_type} STREQUAL ${delft3dfm_configuration}) message(STATUS "Generating solution for Delft3D-FM ...") include(configurations/delft3dfm_configuration.cmake) endif() # Delft3D4 configuration (dflow2d3d, dwaq, dwaves, and some tools) if(${configuration_type} STREQUAL ${delft3d4_configuration}) message(STATUS "Generating solution for Delft3D4 ...") include(configurations/delft3d4_configuration.cmake) endif() # ALL configuration if(${configuration_type} STREQUAL ${all_configuration}) message(STATUS "Generating solution for all (open-source) projects in OSS tree ...") include(configurations/all_configuration.cmake) endif()