Commit e8327d3b authored by Roland Gosda's avatar Roland Gosda
Browse files

Fixed order of additional options required for Windows and added an interface...

Fixed order of additional options required for Windows and added an interface target to facilitate linking.
parent e5bc11e3
......@@ -86,12 +86,14 @@ add_subdirectory(hykops_propeller)
add_subdirectory(hykops_various)
add_subdirectory(hykops_iges)
# linking on windows only works with shared libraries. The DLLs of HYKOPS, Boost-filesystem and iges have to be placed in the path, e.g. the directory the executuable is located in.
# On Windows the necessary DLLs are usually not in the path. Therefore, the DLLs of HYKOPS (if it was build as a shared library), Boost-filesystem and iges have to be placed in the path, e.g. the directory the executuable is located in. To find out which exact DLLs are required, call 'dumpbin.exe /dependents whatever.exe' from a developer shell.
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # needs to be set before the target for HYKOPS is defined
endif()
add_library(HYKOPS ${SOURCES} ${HEADERS})
if(WIN32)
target_compile_definitions(HYKOPS PRIVATE HYKOPS_DLL_EXPORTS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
target_include_directories(HYKOPS PRIVATE
hykops_core
......
......@@ -2,11 +2,12 @@
set_and_check(HYKOPS_INCLUDE_DIR "@PACKAGE_HYKOPS_INCLUDE_INSTALL_DIR@")
set_and_check(HYKOPS_LIBRARIES_DIR "@PACKAGE_HYKOPS_LIBRARIES_INSTALL_DIR@")
include_directories(${HYKOPS_INCLUDE_DIR} ${HYKOPS_INCLUDE_DIR}/hykops_core ${HYKOPS_INCLUDE_DIR}/hykops_data ${HYKOPS_INCLUDE_DIR}/hykops_propeller ${HYKOPS_INCLUDE_DIR}/hykops_iges ${HYKOPS_INCLUDE_DIR}/hykops_various ${HYKOPS_INCLUDE_DIR}/serializeemf)
find_library(HYKOPS_LIBRARY HYKOPS HINTS ${HYKOPS_LIBRARIES_DIR})
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
# Create an interface target to facilitate linking
add_library(HYKOPS INTERFACE)
target_link_libraries(HYKOPS INTERFACE ${HYKOPS_LIBRARY})
target_include_directories(HYKOPS INTERFACE ${HYKOPS_INCLUDE_DIR} ${HYKOPS_INCLUDE_DIR}/hykops_core ${HYKOPS_INCLUDE_DIR}/hykops_data ${HYKOPS_INCLUDE_DIR}/hykops_propeller ${HYKOPS_INCLUDE_DIR}/hykops_iges ${HYKOPS_INCLUDE_DIR}/hykops_various ${HYKOPS_INCLUDE_DIR}/serializeemf)
# Check for standard to use and choose highest (at least 11)
# this is required on Windows to ensure it tries to conform with one of the C++ standards below
......@@ -48,7 +49,7 @@ if (NOT Eigen3_FOUND)
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Eigen3-download )
find_package(Eigen3 3.3 NO_MODULE REQUIRED PATHS "${CMAKE_BINARY_DIR}/external")
endif()
link_libraries(Eigen3::Eigen)
target_link_libraries(HYKOPS INTERFACE Eigen3::Eigen)
# Check for GeometricTools
find_package(GeometricTools)
......@@ -57,7 +58,7 @@ if (NOT GeometricTools_FOUND)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/GeometricTools-download )
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/GeometricTools-download )
# find_package(GeometricTools REQUIRED PATHS "${CMAKE_BINARY_DIR}/external") # TODO not working
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/GeometricTools-src/GTE) # workaround for not finding the package by default
target_include_directories(HYKOPS INTERFACE SYSTEM ${CMAKE_BINARY_DIR}/GeometricTools-src/GTE) # workaround for not finding the package by default
endif()
# Check for pugixml
......@@ -68,7 +69,7 @@ if (NOT pugixml_FOUND)
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pugixml-download )
find_package(pugixml 1.11 REQUIRED PATHS "${CMAKE_BINARY_DIR}/external")
endif()
link_libraries(pugixml)
target_link_libraries(HYKOPS INTERFACE pugixml)
# Check for libIGES
find_package(libIGES)
......@@ -78,12 +79,13 @@ if (NOT libIGES_FOUND)
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/libIGES-download )
# find_package(libIGES REQUIRED PATHS "${CMAKE_BINARY_DIR}/external") # TODO not working
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/external/include/iges) # workaround for not finding the package by default
link_directories(${CMAKE_BINARY_DIR}/external/lib) # workaround for not finding the package by default
link_directories(${CMAKE_BINARY_DIR}/external/bin) # workaround for not finding the package by default on windows, where for some reason the library is installed in the folder bin
target_link_directories(HYKOPS INTERFACE ${CMAKE_BINARY_DIR}/external/lib) # workaround for not finding the package by default
target_link_directories(HYKOPS INTERFACE ${CMAKE_BINARY_DIR}/external/bin) # workaround for not finding the package by default on windows, where for some reason the library is installed in the folder bin
endif()
link_libraries(iges)
target_link_libraries(HYKOPS INTERFACE iges)
# Check for Boost
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(HYKOPS INTERFACE Boost::filesystem Boost::dynamic_linking)
check_required_components(HYKOPS)
check_required_components(HYKOPS_LIBRARY)
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