Skip to content

Commit

Permalink
Cmake improvments (#6945)
Browse files Browse the repository at this point in the history
@mahge
Make building lp_solve optional.
7f7b5f6

    - lp_solve needs bison and flex. These are not available in our
    build-dep packages or docker files we distribute. So make this optional
    for now.

@mahge
TplCodegen.mo generated in Compiler/susan_codegen.
315ea5b

  - TplCodegen.tpl is located in Compiler/susan_codegen. So we generate
    it in that folder and use it from there. No need to copy it to
    Compiler/template like the normal Makefiles do.

@mahge
Generate revision.h from cmake.
fc76fbb

@mahge
Autoconf.mo.omdev.mingw also needs to be generated
a0accc0

  - Autoconf.mo.omdev.mingw now needs generation as well. Not just copy
    only.
  • Loading branch information
mahge committed Nov 16, 2020
1 parent b4fad1a commit 25a593d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
7 changes: 6 additions & 1 deletion OMCompiler/.cmake/omc_utils.cmake
Expand Up @@ -11,4 +11,9 @@ macro(omc_add_subdirectory var)
list(APPEND CMAKE_MESSAGE_CONTEXT ${var})
add_subdirectory(${var})
list(POP_BACK CMAKE_MESSAGE_CONTEXT)
endmacro(omc_add_subdirectory)
endmacro(omc_add_subdirectory)

macro(omc_option var help_text value)
option(${var} ${help_text} ${value})
omc_add_to_report(${var})
endmacro(omc_option)
2 changes: 1 addition & 1 deletion OMCompiler/3rdParty
Submodule 3rdParty updated 1 files
+4 −2 CMakeLists.txt
6 changes: 5 additions & 1 deletion OMCompiler/CMakeLists.txt
Expand Up @@ -61,7 +61,6 @@ option(OMC_USE_CCACHE "Use ccache to speedup compilations." ON)
omc_add_to_report(OMC_USE_CCACHE)



find_program(CCACHE_PROGRAM ccache)
if(OMC_USE_CCACHE AND CCACHE_PROGRAM)
message(STATUS "Found ccache. It will be used for compilation C/C++ sources")
Expand All @@ -72,6 +71,11 @@ endif()



omc_option(OMC_USE_LPSOLVE "Should we use lpsolve." OFF)
omc_option(OMC_BUILD_LPSOLVE "Should we build our own 3rdParty/lpsolve." OFF)




omc_add_subdirectory(3rdParty)

Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/.cmake/meta_modelica_source_list.cmake
Expand Up @@ -113,7 +113,7 @@ set(OMC_MM_ALWAYS_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/Template/GenerateAPIFunctionsTpl.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/SCodeDumpTpl.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/TplAbsyn.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/TplCodegen.mo
${CMAKE_CURRENT_SOURCE_DIR}/susan_codegen/TplCodegen.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/TplMain.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/Tpl.mo
${CMAKE_CURRENT_SOURCE_DIR}/Template/TplParser.mo
Expand Down
35 changes: 31 additions & 4 deletions OMCompiler/Compiler/runtime/CMakeLists.txt
Expand Up @@ -63,10 +63,15 @@ target_link_libraries(omcruntime PUBLIC ${Intl_LIBRARIES})
target_link_libraries(omcruntime PUBLIC Iconv::Iconv)
target_link_libraries(omcruntime PUBLIC ${LAPACK_LIBRARIES})
target_link_libraries(omcruntime PUBLIC omc::simrt::runtime)
target_link_libraries(omcruntime PUBLIC omc::3rd::lpsolve55)
target_link_libraries(omcruntime PUBLIC omc::3rd::libzmq)
target_link_libraries(omcruntime PUBLIC omc::3rd::FMIL::minizip) # We use the minizip lib from 3rdParty/FMIL

if(OMC_USE_LPSOLVE)
target_link_libraries(omcruntime PUBLIC omc::3rd::lpsolve55)
else()
target_compile_definitions(omcruntime PRIVATE NO_LPLIB)
endif()

target_include_directories(omcruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(omcruntime PRIVATE ${OMCompiler_SOURCE_DIR}) # for revision.h

Expand Down Expand Up @@ -125,10 +130,15 @@ target_link_libraries(omcruntime-boot PUBLIC ${Intl_LIBRARIES})
target_link_libraries(omcruntime-boot PUBLIC Iconv::Iconv)
target_link_libraries(omcruntime-boot PUBLIC ${LAPACK_LIBRARIES})
target_link_libraries(omcruntime-boot PUBLIC omc::simrt::runtime)
target_link_libraries(omcruntime-boot PUBLIC omc::3rd::lpsolve55)
target_link_libraries(omcruntime-boot PUBLIC omc::3rd::libzmq)
target_link_libraries(omcruntime-boot PUBLIC omc::3rd::FMIL::minizip) # We use the minizip lib from 3rdParty/FMIL

if(OMC_USE_LPSOLVE)
target_link_libraries(omcruntime-boot PUBLIC omc::3rd::lpsolve55)
else()
target_compile_definitions(omcruntime-boot PRIVATE NO_LPLIB)
endif()

target_include_directories(omcruntime-boot PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(omcruntime-boot PRIVATE ${OMCompiler_SOURCE_DIR}) # for revision.h

Expand Down Expand Up @@ -213,8 +223,10 @@ omc_add_to_report(OMC_TARGET_SYSTEM_NAME)
set(OPENMODELICA_SPEC_PLATFORM ${CMAKE_SYSTEM_PROCESSOR}-${OMC_TARGET_SYSTEM_NAME})

if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(OMC_TARGET_ARCH_IS_64 TRUE)
set(MODELICA_SPEC_PLATFORM "${OMC_TARGET_SYSTEM_NAME}64")
else()
else()
set(OMC_TARGET_ARCH_IS_64 FALSE)
set(MODELICA_SPEC_PLATFORM "${OMC_TARGET_SYSTEM_NAME}32")
endif()

Expand Down Expand Up @@ -259,13 +271,28 @@ set(WITH_UUID "#define WITH_LIBUUID 1")

set(USE_GRAPH 0)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/revision.h.in ${CMAKE_CURRENT_SOURCE_DIR}/revision.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.unix.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.unix.h)


# Generate Autoconf.mo here since we have some of the variables already defined for config.unix.h above.

if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Util/Autoconf.mo.omdev.mingw ${CMAKE_CURRENT_SOURCE_DIR}/../Util/Autoconf.mo COPY_ONLY)

if(OMC_TARGET_ARCH_IS_64)
set(ISMINGW64 "true")
else()
set(ISMINGW64 "false")
endif()

if(${CMAKE_CXX_COMPILER_VERSION} STREQUAL "5.3.0")
set(IS_NEW_OMDEV "false")
else()
set(IS_NEW_OMDEV "true")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Util/Autoconf.mo.omdev.mingw ${CMAKE_CURRENT_SOURCE_DIR}/../Util/Autoconf.mo)

else()
check_c_compiler_flag("-Wl,-Bstatic -Wl,-Bdynamic" BSTATIC_INT)
if(BSTATIC_INT)
Expand Down

0 comments on commit 25a593d

Please sign in to comment.