Skip to content

Commit

Permalink
[cmake] General improvements to CMake config.
Browse files Browse the repository at this point in the history
  - 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.
  • Loading branch information
mahge committed Aug 23, 2021
1 parent e30e00a commit c1adfd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion OMCompiler/.cmake/omc_utils.cmake
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions 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
Expand All @@ -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)

#########################################################################################################
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/SimulationRuntime/c/cmake_3.14.cmake
Expand Up @@ -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
Expand Down

0 comments on commit c1adfd7

Please sign in to comment.