Skip to content

Commit

Permalink
[cmake] Multiple fixes for Windows build.
Browse files Browse the repository at this point in the history
  - omc_config.h is in OMCompier.
    - It used to be in OMCompier/Compiler/runtime. It was moved a while
      back but the windows Makefile was still 'touching' it in the old
      folder and ending up creating an empty file.

  - Do not specify -rdynamic for omc on Windows.

  - Install the scripts (Compiler/scripts) to the share dir.

  - Link with wsock32 and ws2_32 where needed.
  • Loading branch information
mahge committed Oct 29, 2021
1 parent dde8a6d commit 331aa1d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion OMCompiler/Compiler/CMakeLists.txt
Expand Up @@ -219,7 +219,9 @@ target_link_libraries(OpenModelicaCompiler PUBLIC omc::3rd::Modelica::IO)
add_executable(omc .cmake/omc_main.c)
target_link_libraries(omc PRIVATE OpenModelicaCompiler)

target_link_options(omc PRIVATE -rdynamic)
if(NOT WIN32)
target_link_options(omc PRIVATE -rdynamic)
endif()

# if(MINGW)
# target_link_options(omc PRIVATE -Wl,--stack,33554432)
Expand Down Expand Up @@ -251,6 +253,10 @@ install(FILES FrontEnd/PDEModelicaBuiltin.mo
DESTINATION lib/omc
COMPONENT compiler)

# Install the scripts to 'share' dir.
install(DIRECTORY scripts
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/omc/)


# This is a convenience target to install omc. We are used to issuing 'make install' to install
# components. CMake uses a separate install script to perform installations. This custom command
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Makefile.omdev.mingw
Expand Up @@ -192,7 +192,7 @@ else # revision is not empty, update it if it changed
then \
echo "#define CONFIG_REVISION \"OpenModelica $(CONFIG_REVISION) $(PLATFORM_ARCH)\"" > revision.h.tmp; diff revision.h revision.h.tmp > /dev/null; \
if [ $$? -eq 0 ]; then echo No change in revision; rm revision.h.tmp; \
else echo Revision has changed. updating revision.h; \mv revision.h.tmp revision.h; touch Compiler/runtime/omc_config.h; \
else echo Revision has changed. updating revision.h; \mv revision.h.tmp revision.h; touch omc_config.h; \
fi; \
else \
echo "#define CONFIG_REVISION \"OpenModelica $(CONFIG_REVISION) $(PLATFORM_ARCH)\"" > revision.h; echo Retrieved revision number. revision.h was created; \
Expand Down
4 changes: 4 additions & 0 deletions OMCompiler/SimulationRuntime/c/cmake_3.14.cmake
Expand Up @@ -95,6 +95,10 @@ target_link_libraries(SimulationRuntimeC PUBLIC omc::3rd::cminpack)
target_link_libraries(SimulationRuntimeC PUBLIC omc::3rd::cdaskr)
target_link_libraries(SimulationRuntimeC PUBLIC omc::3rd::lis)

if(WIN32)
target_link_libraries(OpenModelicaRuntimeC PUBLIC wsock32)
endif(WIN32)

# Fix me. Make an interface (header only library) out of 3rdParty/dgesv
target_include_directories(SimulationRuntimeC PRIVATE ${OMCompiler_SOURCE_DIR}/3rdParty/dgesv/include/)

Expand Down
Expand Up @@ -20,6 +20,11 @@ target_link_libraries(OMCppOMCFactory PUBLIC Boost::filesystem)
target_link_libraries(OMCppOMCFactory PUBLIC Threads::Threads)
target_link_libraries(OMCppOMCFactory PUBLIC ${CMAKE_DL_LIBS})

if(WIN32)
target_link_libraries(OMCppOMCFactory PUBLIC wsock32)
target_link_libraries(OMCppOMCFactory PUBLIC ws2_32)
endif()

target_link_options(OMCppOMCFactory PRIVATE -Wl,--no-undefined)

install(TARGETS OMCppOMCFactory)
Expand Down

0 comments on commit 331aa1d

Please sign in to comment.