From c1adfd75f5f6ac855f01457d5f36f594e5b470ef Mon Sep 17 00:00:00 2001 From: Mahder Gebremedhin Date: Sun, 22 Aug 2021 12:06:50 +0200 Subject: [PATCH] [cmake] General improvements to CMake config. - Allow calling omc_add_to_report with a variable that is not set. Some variables can be set or not depending on configuration. This used to cause errors when the variable was unset and also added to report. - Explicitly tell cmake our project needs C CXX and Fortran. Just to get the initial reports of compiler info at the beginning of configuration. - Add CXX and Fortran compiler IDs to the printed report. - Install `libomcmemory`. It was overlooked before. --- OMCompiler/.cmake/omc_utils.cmake | 5 ++++- OMCompiler/CMakeLists.txt | 5 +++-- OMCompiler/SimulationRuntime/c/cmake_3.14.cmake | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OMCompiler/.cmake/omc_utils.cmake b/OMCompiler/.cmake/omc_utils.cmake index 4da25205c9e..216e5820c3a 100644 --- a/OMCompiler/.cmake/omc_utils.cmake +++ b/OMCompiler/.cmake/omc_utils.cmake @@ -3,7 +3,10 @@ include(CMakePrintHelpers) macro(omc_add_to_report var) cmake_print_variables(${var}) - add_feature_info(${var} ${var} ${${var}}) + # quote to change variables with empty values to "" (empty string). + # Otherwise they will valuate to nothing and that will cause a + # syntax error since add_feature_info expects 3 arguments. + add_feature_info(${var} ${var} "${${var}}") endmacro(omc_add_to_report) set(CMAKE_MESSAGE_CONTEXT_SHOW ON) diff --git a/OMCompiler/CMakeLists.txt b/OMCompiler/CMakeLists.txt index 4bcf0eb32b4..26356949c17 100644 --- a/OMCompiler/CMakeLists.txt +++ b/OMCompiler/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.14) -project(OMCompiler) +project(OMCompiler C CXX Fortran) # Variable for signifying that we are using the new CMake configuration. # We use this to selectively include some cmake source files @@ -25,8 +25,9 @@ include(.cmake/omc_target_info.cmake) include(.cmake/omc_check_exists.cmake) # Add the compiler ids to the report for convenience. -omc_add_to_report(CMAKE_CXX_COMPILER_ID) omc_add_to_report(CMAKE_C_COMPILER_ID) +omc_add_to_report(CMAKE_CXX_COMPILER_ID) +omc_add_to_report(CMAKE_Fortran_COMPILER_ID) omc_add_to_report(CMAKE_LIBRARY_ARCHITECTURE) ######################################################################################################### diff --git a/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake b/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake index f392dd89b01..d1b1dfcf84b 100644 --- a/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake +++ b/OMCompiler/SimulationRuntime/c/cmake_3.14.cmake @@ -44,6 +44,7 @@ target_sources(omcmemory PRIVATE ${OMC_SIMRT_GC_SOURCES}) target_link_libraries(omcmemory PUBLIC omc::3rd::omcgc) target_include_directories(omcmemory PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +install(TARGETS omcmemory) # ###################################################################################################################### # Library: OpenModelicaRuntimeC