diff --git a/CMakeLists.txt b/CMakeLists.txt index 707a2babe..61d88819d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,6 @@ openvic_disable_rtti() option(OPENVIC_USE_PCH "Precompile openvic-simulation/pch.hpp" ON) -add_subdirectory(deps) - file(GLOB_RECURSE sim_sources CONFIGURE_DEPENDS src/openvic-simulation/*.cpp) list(REMOVE_ITEM sim_sources ${CMAKE_CURRENT_SOURCE_DIR}/src/openvic-simulation/pch.cpp) @@ -88,12 +86,29 @@ target_link_libraries( ov_foonathan_memory ) -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +# all Unix (non Apple) systems find TBB via pkg_config +if(UNIX AND NOT APPLE) find_package(PkgConfig REQUIRED) - pkg_check_modules(TBB REQUIRED IMPORTED_TARGET tbb) - target_link_libraries(openvic-simulation PUBLIC PkgConfig::TBB) + pkg_check_modules(TBB_PC REQUIRED IMPORTED_TARGET GLOBAL tbb) + target_link_libraries(openvic-simulation PUBLIC PkgConfig::TBB_PC) +endif() + +# any platform specific code can be added below +# OpenBSD needs explicit iconv detection so far +if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + find_path(ICONV_INCLUDE_DIR iconv.h) + find_library(ICONV_LIBRARY NAMES iconv) + + if(NOT ICONV_INCLUDE_DIR OR NOT ICONV_LIBRARY) + message(FATAL_ERROR "iconv not found, try installing it") + endif() + + include_directories(${ICONV_INCLUDE_DIR}) + link_libraries(${ICONV_LIBRARY}) endif() +add_subdirectory(deps) + if(APPLE) # clang emits the TLS init aliases (_ZTH*) for inline thread_local members # as non-weak private-external symbols, one per TU that odr-uses them, and diff --git a/CMakePresets.json b/CMakePresets.json index 54856a603..979b08091 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -55,6 +55,20 @@ "CMAKE_CXX_COMPILER": "g++" } }, + { + "name": "bsd-x64", + "inherits": "base", + "generator": "Ninja Multi-Config", + "condition": { + "type": "matches", + "string": "${hostSystemName}", + "regex": "^.*BSD.*$" + }, + "cacheVariables": { + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_MAKE_PROGRAM": "ninja" + } + }, { "name": "macos-universal", "inherits": "base", @@ -114,6 +128,21 @@ "configurePreset": "linux-x64", "configuration": "RelWithDebInfo" }, + { + "name": "bsd-x64-release", + "configurePreset": "bsd-x64", + "configuration": "Release" + }, + { + "name": "bsd-x64-debug", + "configurePreset": "bsd-x64", + "configuration": "Debug" + }, + { + "name": "bsd-x64-relwithdebinfo", + "configurePreset": "bsd-x64", + "configuration": "RelWithDebInfo" + }, { "name": "macos-universal-release", "configurePreset": "macos-universal", @@ -167,6 +196,18 @@ "configuration": "Release", "output": { "outputOnFailure": true } }, + { + "name": "bsd-x64-debug", + "configurePreset": "bsd-x64", + "configuration": "Debug", + "output": { "outputOnFailure": true } + }, + { + "name": "bsd-x64-release", + "configurePreset": "bsd-x64", + "configuration": "Release", + "output": { "outputOnFailure": true } + }, { "name": "macos-universal-debug", "configurePreset": "macos-universal",