Closed markaren closed 5 years ago
There might be an issue on linux. Will investigate and update the pull request later.
I tried this branch.
Note: when building fmi4cpp on windows -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON needs to be passed to CMake (this is done by the vcpkg port)
I suggest to move this to the main CMakeLists.txt, to simplify the process of building this library with BUILD_SHARED_LIBS
outside of vcpkg, for using ExternalProject (useful for CMake-based superbuilds) of for including this library inside of another project using FetchContent and add_subdirectory
.
Furthermore, on an empty build on Ubuntu 18.04, I have this error:
CMake Error at CMakeLists.txt:18 (string):
string sub-command COMPARE, mode EQUAL needs at least 5 arguments total to
command.
this is because the line string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "Debug" DEBUG_MODE)
is equivalent to string(COMPARE EQUAL "Debug" DEBUG_MODE)
if CMAKE_BUILD_TYPE
is empty (the default value). Substituting it with string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Debug" DEBUG_MODE)
fixes this specific problem, but that logic is still broken for multiple-config generators such as Visual Studio.
You may be interested in substuting all that logic with a simple target_compile_definitions
call once the ${FMI4CPP_LIB}
library has been created:
target_compile_definitions(${FMI4CPP_LIB} PRIVATE $<$<CONFIG:Debug>:DEBUG_LOGGING_ENABLED>)
See https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html for more info on the generator expressions.
this is because the line
string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "Debug" DEBUG_MODE)
is equivalent tostring(COMPARE EQUAL "Debug" DEBUG_MODE)
ifCMAKE_BUILD_TYPE
is empty (the default value). Substituting it withstring(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Debug" DEBUG_MODE)
fixes this specific problem, but that logic is still broken for multiple-config generators such as Visual Studio. You may be interested in substuting all that logic with a simpletarget_compile_definitions
call once the${FMI4CPP_LIB}
library has been created:target_compile_definitions(${FMI4CPP_LIB} PRIVATE $<$<CONFIG:Debug>:DEBUG_LOGGING_ENABLED>)
Thanks, tested the target_compile_definitions
solution. Seems more elegant, applying to dev directly.
Note: when building fmi4cpp on windows -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON needs to be passed to CMake (this is done by the vcpkg port)
I suggest to move this to the main CMakeLists.txt, to simplify the process of building this library with
BUILD_SHARED_LIBS
outside of vcpkg, for using ExternalProject (useful for CMake-based superbuilds) of for including this library inside of another project using FetchContent andadd_subdirectory
.
I'm adding this directly to the project's CMakeList.txt as suggested.
Updates the CMake files so that it can be cleanly installed by vcpkg. To use the library, client applications just need to add
Note: when building fmi4cpp on windows
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON
needs to be passed to CMake (this is done by the vcpkg port)@traversaro I basically had to rewrite the install code as I was following this example. Please have a look.
Relates to #4