Commit 0c33aeeb authored by GILLES Sebastien's avatar GILLES Sebastien

#1217 Read compiler informations from Path file, with possibility to override from command line.

parent 89892c47
......@@ -2,7 +2,25 @@
cmake_minimum_required(VERSION 3.8)
# TODO Add check whether the provided value is valid.
# ===================================================================================================================
# Include a file with default setting. Some of them might be overriden by command line, such as the C or C++ compiler.
# ===================================================================================================================
if(NOT PATH_FILE)
message(FATAL_ERROR "-DPATH_FILE must be present in the command line and point to a file that specify the paths and settings to use in the build. A default one is defined in cmake/Paths.cmake; feel free to copy and adapt it to your needs.")
endif()
include(${PATH_FILE})
# ===================================================================================================================
# Set some values in the path file that night be overridden by cache variables.
# WARNING: all those calls must occur BEFORE the call to project, so that overriding remains possible.
# ===================================================================================================================
# From https://cmake.org/pipermail/cmake/2008-September/023808.html
# Ensure if the user doesn't specify arenything in command line debug is chosen (CMake default is no optimization and no debug symbol, which is rather useless).
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
......@@ -13,11 +31,19 @@ options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel.")
endif()
# Set C and CXX compilers from the values read in the setting file. Might be overridden in command line.
set(CMAKE_C_COMPILER ${CC} CACHE STRING "C compiler (or the Mpi wrapper over it).")
set(CMAKE_CXX_COMPILER ${CXX} CACHE STRING "C++ compiler (or the Mpi wrapper over it).")
# ===================================================================================================================
# Set project.
# ===================================================================================================================
project( "MoReFEM_CMAKE")
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
......@@ -28,11 +54,7 @@ MESSAGE("Module path: ${CMAKE_MODULE_PATH}")
include(CustomCommands)
if(NOT PATH_FILE)
message(FATAL_ERROR "-DPATH_FILE must be present in the command line and point to a file that specify the paths and settings to use in the build. A default one is defined in cmake/Paths.cmake; feel free to copy and adapt it to your needs.")
endif()
include(${PATH_FILE})
# All --all_load in target_link_libraries of executables if STATIC library are chose.
......@@ -55,11 +77,6 @@ else()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
message("CMAKE_C_COMPILER " ${CMAKE_C_COMPILER})
message("CMAKE_C_COMPILER_ID" ${CMAKE_C_COMPILER_ID})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Tclap/include /
${OPS_DIR} /
......
......@@ -16,7 +16,7 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang" OR ${CMAKE_C_COMPILER_ID} STREQU
add_cxx_compiler_flag("-stdlib=libc++")
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions("_LIBCPP_DEBUG2=0") # Additional checks such as index out of bounds in vectors in libc++; might
add_definitions(-D_LIBCPP_DEBUG2=0) # Additional checks such as index out of bounds in vectors in libc++; might
# be removed at any point from libc++.
endif()
......
# Choose C and C++ compilers. You might also specifies here clang static analyzer (paths to ccc-analyzer and c++-analyzer respectively) to perform static analysis of the code.
set(COMPILER 'clang )
set(COMPILER_DIRECTORY 'clang )
set(CC /Users/Shared/LibraryVersions/clang/Openmpi/bin/mpicc )
set(CXX /Users/Shared/LibraryVersions/clang/Openmpi/bin/mpic++ )
set(CC /Users/Shared/LibraryVersions/llvm-clang/Openmpi/bin/mpicc )
set(CXX /Users/Shared/LibraryVersions/llvm-clang/Openmpi/bin/mpic++ )
# Choose either 'debug' or 'release'.
set(MODE debug)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment