diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 16e50421a8..2995719f26 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -1,4 +1,5 @@ trigger: + batch: true branches: exclude: - pre-commit/* @@ -196,7 +197,7 @@ jobs: # ----------------------- # Test HELICS # ----------------------- - - bash: ctest --output-on-failure --timeout 480 -C Release -L "Continuous" + - bash: ctest --output-on-failure --timeout 1000 -C Release -L "Continuous" displayName: 'Test HELICS' workingDirectory: build diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index ff7c4ed10c..cb36d3e5a5 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -39,6 +39,7 @@ jobs: - name: Build HELICS run: | unset VCPKG_ROOT + git config --global --add safe.directory ${GITHUB_WORKSPACE} source scripts/setup-helics-ci-options.sh mkdir -p build && cd build ../scripts/ci-build.sh diff --git a/.gitignore b/.gitignore index 7852fcaf8d..7dc1329302 100644 --- a/.gitignore +++ b/.gitignore @@ -257,3 +257,6 @@ tags *.mex* .DS_Store HELICS_xcode + +### Backup files +*.bak diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c98ca7501f..78c20150b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: dockerfile_lint args: [--rulefile, ./config/Docker/docker_rules.yml, --dockerfile] - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black args: ["--line-length=100"] @@ -40,7 +40,7 @@ repos: - id: detect-private-key exclude: ^(tests/helics/test_files/encryption_config/openssl_certs/) - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.0 + rev: v3.0.0-alpha.2 hooks: - id: prettier exclude: ^(docs/user-guide/examples/user_guide_examples) @@ -60,9 +60,9 @@ repos: rev: v0.6.13 hooks: - id: cmake-format - exclude: "cmake+" + exclude: "cmake_+" - repo: https://github.com/codespell-project/codespell - rev: v2.2.1 + rev: v2.2.2 hooks: - id: codespell exclude: ^(docs/user-guide/examples/user_guide_examples) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f2f6c6c94..4deb89127c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,35 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm A note on future revisions. Everything within a major version number should be code compatible (with the exception of experimental interfaces). The most notable example of an experimental interface is the support for multiple source inputs. The APIs to deal with this will change in future minor releases. Everything within a single minor release should be network compatible with other federates on the same minor release number. Compatibility across minor release numbers may be possible in some situations but we are not going to guarantee this as those components are subject to performance improvements and may need to be modified at some point. Patch releases will be limited to bug fixes and other improvements not impacting the public API or network compatibility. Check the [Public API](./docs/Public_API.md) for details on what is included and excluded from the public API and version stability. -## [3.3.0][] ~ 2022-08-07 +## [3.3.1][] ~ 2022-10-21 + +Patch release to fix some issues with using HELICS as a subproject, and fix a few bugs related to time barriers, and a few other timing issues. + +### Fixed + +- Fixed an issue where broker based time barriers were not propagating to new federates. +- Fix the code coverage build system. +- Fixed a potential race condition with callback federates if the callback operations are modified during cosimulation. +- Fixed timing synchronization issue with global time coordinator. + +### Changed + +- Cleaned up usage of HELICS in external subprojects and adding some cleanup features, also cleanup the CMake usage to divide some operations into included files to simplify the main CMakeLists.txt +- Changed the default behavior for profiler output files to create a new file instead of appending. Use `--profiler_append=` to maintain the old behavior. + +### Added + +- Added single thread federate support which includes a federate optimized for use in a single thread.(Corresponding single thread core will come in next release). +- Added support for initialization iteration to allow federates to specify ready and then return to the created mode to do additional initialization potentially with information from other federates. +- Added flag to disable remote termination commands. +- Added C API function calls for alias operations. +- Added read only property HELICS_PROPERTY_INT_ITERATION_COUNT to get the current iteration count for a federate. + +### Removed + +- Removed an unused and unexposed method in the Core API to retrieve the current iteration count, use HELICS_PROPERTY_INT_ITERATION_COUNT with getProperty to retrieve the same data. + +## [3.3.0][] - 2022-09-15 Minimum build requirements updated to CMake 3.11, Visual Studio 2019, XCode 11.0, GCC 8.1, Clang 7.0. The major new features include a callback federate, and aliases to allow interfaces to have multiple string names. @@ -55,13 +83,11 @@ The release also includes several bug fixes related to timing and iteration. - Added a [callback Federate](https://docs.helics.org/en/latest/user-guide/advanced_topics/CallbackFederate.html) capability which allows a large number of callback based federates to execute on a single core without direct user calls - Added some additional [callbacks](https://docs.helics.org/en/latest/user-guide/advanced_topics/callbacks.html) for federates - Added flags on the webserver to allow much easier configuration to external network interfaces -- Added read only property HELICS_PROPERTY_INT_ITERATION_COUNT to get the current iteration count for a federate ### Removed - ghc::filesystem, since all minimum compilers have support for std::filesystem available. - Removed Travis CI related configuration and documentation -- Removed an unused and unexposed method in the Core API to retrieve the current iteration count, use HELICS_PROPERTY_INT_ITERATION_COUNT with getProperty to retrieve the same data. ## [3.2.1][] - 2022-06-17 @@ -292,6 +318,8 @@ HELICS 3.0 is a major update to HELICS. The major features that have been added [3.1.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.1.1 [3.1.2]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.1.2 [3.2.0]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.2.0 -[3.2.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.2.0 +[3.2.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.2.1 +[3.3.0]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.3.0 +[3.3.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.3.1 The changelog for HELICS 1.X and 2.X can be found [here](./docs/HELICS2_CHANGELOG.md) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d3d23116e..29d2757f2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,14 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT HELICS_D set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") endif() -project(HELICS VERSION 3.3.0) +project(HELICS VERSION 3.3.1) # ----------------------------------------------------------------------------- # HELICS Version number # ----------------------------------------------------------------------------- set(HELICS_VERSION_BUILD) # use ISO date YYYY-MM-DD -set(HELICS_DATE "2022-09-15") +set(HELICS_DATE "2022-10-21") set(HELICS_VERSION_UNDERSCORE "${HELICS_VERSION_MAJOR}_${HELICS_VERSION_MINOR}_${HELICS_VERSION_PATCH}" @@ -44,15 +44,22 @@ message(STATUS "SYSTEM INFO -> ${HELICS_COMPILER_VERSION}") # ----------------------------------------------------------------------------- if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/config/cmake/" "${PROJECT_SOURCE_DIR}/ThirdParty/cmake/" ) else() - set(ORIGINAL_MODULE_PATH ${CMAKE_MODULE_PATH}) + set(${PROJECT_NAME}_ORIGINAL_MODULE_PATH ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/config/cmake/" "${PROJECT_SOURCE_DIR}/ThirdParty/cmake/" ${CMAKE_MODULE_PATH} ) + +endif() + +include(commonBuildPaths) + +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() get_property(helics-use-folders GLOBAL PROPERTY USE_FOLDERS) endif() @@ -74,83 +81,6 @@ include(extraMacros) include(CMakeDependentOption) include(copy_key_files) include(CTest) -include(ucm) - -# include(BuildType) -# ----------------------------------------------------------------------------- -# set the install path to a local directory -# ----------------------------------------------------------------------------- -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - if(WIN32) - if(MSVC) - set(CMAKE_INSTALL_PREFIX "C:/local/helics_${HELICS_VERSION_UNDERSCORE}/" - CACHE PATH "default install path" FORCE - ) - elseif(MINGW AND NOT MSYS) - set(CMAKE_INSTALL_PREFIX "C:/local/helics_${HELICS_VERSION_UNDERSCORE}/" - CACHE PATH "default install path" FORCE - ) - elseif(MSYS) - # use CMAKE_OBJCOPY here since it is somewhat less likely to be overridden by users - # rather than the compiler - get_filename_component(path_bin ${CMAKE_OBJCOPY} DIRECTORY) - get_filename_component(path_install ${path_bin} DIRECTORY) - set(CMAKE_INSTALL_PREFIX ${path_install} CACHE PATH "default install path" FORCE) - endif(MSVC) - endif(WIN32) -endif() - -# Warning if CMAKE_INSTALL_PREFIX is empty. Likely set by using the wrong environment variable. -if(NOT CMAKE_INSTALL_PREFIX) - message( - WARNING - "CMAKE_INSTALL_PREFIX is set to nothing. If you are using an environment variable for handling prefix paths, that variable might not have been set before using it with CMake to set the CMAKE_INSTALL_PREFIX option." - ) -endif() - -# Check to make sure the install prefix isn't the build folder, if it is, build errors will happen -get_filename_component(tmp_install_prefix "${CMAKE_INSTALL_PREFIX}" REALPATH) -get_filename_component(tmp_proj_bindir "${PROJECT_BINARY_DIR}" REALPATH) -# Windows paths are case insensitive -if(WIN32) - string(TOLOWER "${tmp_install_prefix}" tmp_install_prefix) - string(TOLOWER "${tmp_proj_bindir}" tmp_proj_bindir) -endif() -if(tmp_install_prefix STREQUAL tmp_proj_bindir) - message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must not be set to the build folder") -endif() - -if(MSYS - OR CYGWIN - OR UNIX - OR APPLE -) - set(UNIX_LIKE TRUE) -endif() - -# Set the build output paths -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH - "Archive output dir." - ) - endif() - if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH - "Library output dir." - ) - endif() - if(NOT CMAKE_PDB_OUTPUT_DIRECTORY) - set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" - CACHE PATH "PDB (MSVC debug symbol)output dir." - ) - endif() - if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" - CACHE PATH "Executable/dll output dir." - ) - endif() -endif() if(NOT CMAKE_VERSION VERSION_LESS 3.12) option( @@ -250,74 +180,16 @@ cmake_dependent_advanced_option( HELICS_ENABLE_DEBUG_LOGGING "enable debug logging" ON "HELICS_ENABLE_LOGGING" ON ) -# ----------------------------------------------------------------------------- -# General project wide configuration for debug postfix -# ----------------------------------------------------------------------------- -if(NOT NO_DEBUG_POSFIX AND NOT CMAKE_DEBUG_POSTFIX) - set(CMAKE_DEBUG_POSTFIX d) -endif() +include(commonBuildFlags) # add a baseline library for underlying dependencies and flags add_library(helics_base INTERFACE) -# Prohibit in-source build -if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) - message( - FATAL_ERROR - "In-source build is not supported. Please, use an empty directory for building the project." - ) -endif() - -if(NOT TARGET compile_flags_target) - add_library(compile_flags_target INTERFACE) -endif() - -if(NOT TARGET build_flags_target) - add_library(build_flags_target INTERFACE) -endif() - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - mark_as_advanced(BUILD_TESTING) - include(compiler_flags) - -endif() - add_library(HELICS::compile_flags_target ALIAS compile_flags_target) add_library(HELICS::build_flags_target ALIAS build_flags_target) get_target_property(EXTRA_BUILD_FLAGS build_flags_target INTERFACE_COMPILE_OPTIONS) -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - if(NOT USE_LIBCXX) - show_variable(STATIC_STANDARD_LIB STRING "Link against a static standard lib" default) - set_property(CACHE STATIC_STANDARD_LIB PROPERTY STRINGS default static dynamic) - else() - hide_variable(STATIC_STANDARD_LIB) - endif() - if(MSVC) - show_variable(HELICS_EMBEDDED_DEBUG_INFO STRING "embed debug info into lib files" default) - set_property(CACHE HELICS_EMBEDDED_DEBUG_INFO PROPERTY STRINGS default embedded external) - else() - hide_variable(HELICS_EMBEDDED_DEBUG_INFO) - endif() -endif() - -if(STATIC_STANDARD_LIB STREQUAL "default") - -elseif(STATIC_STANDARD_LIB STREQUAL "static") - ucm_set_runtime(STATIC) -elseif(STATIC_STANDARD_LIB STREQUAL "dynamic") - ucm_set_runtime(DYNAMIC) -endif() - -if(HELICS_EMBEDDED_DEBUG_INFO STREQUAL "default") - -elseif(HELICS_EMBEDDED_DEBUG_INFO STREQUAL "external") - ucm_set_embedded_debug(EXTERNAL) -else() - ucm_set_embedded_debug(EMBEDDED) -endif() - # ------------------------------------------------------------- # add coverage target # ------------------------------------------------------------- @@ -431,12 +303,14 @@ endif() # ------------------------------------------------------------- # TOML11 add the TOML interpreter # ------------------------------------------------------------- +if(NOT TARGET toml11::toml11) + set(toml11_BUILD_TEST OFF CACHE INTERNAL "") + set(toml11_TEST_WITH_ASAN OFF CACHE INTERNAL "") + set(toml11_TEST_WITH_UBSAN OFF CACHE INTERNAL "") + set(toml11_INSTALL OFF CACHE INTERNAL "") + add_subdirectory(ThirdParty/toml EXCLUDE_FROM_ALL) -set(toml11_BUILD_TEST OFF CACHE INTERNAL "") -set(toml11_TEST_WITH_ASAN OFF CACHE INTERNAL "") -set(toml11_TEST_WITH_UBSAN OFF CACHE INTERNAL "") -set(toml11_INSTALL OFF CACHE INTERNAL "") -add_subdirectory(ThirdParty/toml EXCLUDE_FROM_ALL) +endif() # ------------------------------------------------------------- # options for enabling specific core communication types @@ -616,45 +490,8 @@ if(NOT HELICS_DISABLE_ASIO) INTERFACE $ ) endif() -# ------------------------------------------------------------- -# setting the RPATH -# ------------------------------------------------------------- -if(NOT DEFINED CMAKE_MACOSX_RPATH) - set(CMAKE_MACOSX_RPATH ON) -endif() - -# add the automatically determined parts of the RPATH which point to directories outside the build -# tree to the install RPATH -if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -endif() - -# Add the local directory to the rpath -if(NOT APPLE) - list(APPEND CMAKE_INSTALL_RPATH $ORIGIN) - list(APPEND CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") -else() - list(APPEND CMAKE_INSTALL_RPATH "@loader_path") - list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") - list(APPEND CMAKE_INSTALL_RPATH "@executable_path") - list(APPEND CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") -endif() - -# the RPATH to be used when installing, but only if it's not a system directory -list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" isSystemDir -) -if(isSystemDir STREQUAL "-1") - list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") -endif() - -list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir -) -if(isSystemDir STREQUAL "-1") - list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -endif() +include(commonRPath) if(NOT WIN32) if(HELICS_ENABLE_ZMQ_CORE AND NOT HELICS_USE_ZMQ_STATIC_LIBRARY) get_target_property(zmqlibfile libzmq IMPORTED_LOCATION) @@ -684,9 +521,6 @@ include(addfmt) # Create the target for jsoncpp # ----------------------------------------------------------- include(addJsoncpp) -if(TARGET jsoncpp_static AND NOT TARGET JsonCpp::JsonCpp) - add_library(HELICS::jsoncpp ALIAS jsoncpp_static) -endif() # -------------------------------------------------------------- # Create the target for spdlog @@ -701,64 +535,13 @@ include(addUnits) # ----------------------------------------------------------------------------- # create utilities target # ----------------------------------------------------------------------------- - -set(GMLC_UTILITIES_INSTALL OFF CACHE INTERNAL "") - -add_subdirectory(ThirdParty/utilities) - -hide_variable(GMLC_UTILITIES_GENERATE_DOXYGEN_DOC) -hide_variable(GMLC_UTILITIES_INCLUDE_BOOST) -hide_variable(GMLC_UTILITIES_USE_BOOST_SPIRIT) -hide_variable(GMLC_UTILITIES_WITH_CMAKE_PACKAGE) -hide_variable(GMLC_UTILITIES_OBJECT_LIB) -hide_variable(GMLC_UTILITIES_STATIC_LIB) -hide_variable(GMLC_UTILITIES_CLANG_TIDY_OPTIONS) - -target_compile_definitions(gmlc_utilities PUBLIC USE_STD_STRING_VIEW=1) - -set_target_properties(gmlc_utilities PROPERTIES FOLDER Extern) -if(NOT HELICS_DISABLE_BOOST) - target_include_directories( - gmlc_utilities SYSTEM PRIVATE $ - ) -endif() +include(addUtilities) # ----------------------------------------------------------------------------- # create networking target # ----------------------------------------------------------------------------- -set(GMLC_NETWORKING_INSTALL OFF CACHE INTERNAL "") -set(GMLC_NETWORKING_ASIO_INCLUDE ${PROJECT_SOURCE_DIR}/ThirdParty/asio/asio/include) -set(GMLC_NETWORKING_CONCURRENCY_INCLUDE ${PROJECT_SOURCE_DIR}/ThirdParty/concurrency) -set(GMLC_NETWORKING_DISABLE_ASIO ${HELICS_DISABLE_ASIO} CACHE INTERNAL "") - -# hide some of the JSON in the networking library -set(JSON_CI OFF CACHE INTERNAL "") -set(JSON_Diagnostics OFF CACHE INTERNAL "") -set(JSON_ImplicitConversions ON CACHE INTERNAL "") -set(JSON_Install OFF CACHE INTERNAL "") -set(JSON_MultipleHeaders OFF CACHE INTERNAL "") -set(JSON_SystemInclude OFF CACHE INTERNAL "") - -if(HELICS_ENABLE_ENCRYPTION) - list(APPEND VCPKG_MANIFEST_FEATURES "encryption") - set(GMLC_NETWORKING_ENABLE_ENCRYPTION ON CACHE INTERNAL "") -else() - set(GMLC_NETWORKING_ENABLE_ENCRYPTION OFF CACHE INTERNAL "") -endif() - -add_subdirectory(ThirdParty/networking) - -hide_variable(GMLC_NETWORKING_GENERATE_DOXYGEN_DOC) -hide_variable(GMLC_NETWORKING_INCLUDE_BOOST) -hide_variable(GMLC_NETWORKING_WITH_CMAKE_PACKAGE) -hide_variable(GMLC_NETWORKING_OBJECT_LIB) -hide_variable(GMLC_NETWORKING_STATIC_LIB) -hide_variable(GMLC_NETWORKING_CLANG_TIDY_OPTIONS) -hide_variable(GMLC_NETWORKING_ENABLE_SUBMODULE_UPDATE) -hide_variable(GMLC_NETWORKING_USE_EXTERNAL_JSON) - -set_target_properties(gmlc_networking PROPERTIES FOLDER Extern) +include(addNetworking) # ----------------------------------------------------------------------------- # CMAKE Subdirectories @@ -1038,12 +821,10 @@ if(HELICS_ENABLE_PACKAGE_BUILD) headers libs swig - matlab java octave csharp benchmarks - cereal ) if(WIN32) set(CPACK_RESOURCE_FILE_LICENSE "${HELICS_SOURCE_DIR}\\\\LICENSE") @@ -1166,10 +947,46 @@ endif(HELICS_ENABLE_PACKAGE_BUILD) if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # restore the original module path - set(CMAKE_MODULE_PATH ${ORIGINAL_MODULE_PATH}) + set(CMAKE_MODULE_PATH ${${PROJECT_NAME}_ORIGINAL_MODULE_PATH}) if(old_build_shared) set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) endif() + + if(HELICS_HIDE_CMAKE_VARIABLES) + hide_variable(HELICS_BINARY_ONLY_INSTALL) + hide_variable(HELICS_BUILD_APP_LIBRARY) + hide_variable(HELICS_BUILD_CONFIGURATION) + hide_variable(HELICS_BUILD_CXX_SHARED_LIB) + hide_variable(HELICS_DISABLE_ASIO) + hide_variable(HELICS_DISABLE_BOOST) + hide_variable(HELICS_DISABLE_C_SHARED_LIB) + hide_variable(HELICS_DISABLE_WEBSERVER) + hide_variable(HELICS_DISABLE_VCPKG) + hide_variable(HELICS_ENABLE_DEBUG_LOGGING) + hide_variable(HELICS_ENABLE_ENCRYPTION) + hide_variable(HELICS_ENABLE_INPROC_CORE) + hide_variable(HELICS_ENABLE_LOGGING) + hide_variable(HELICS_ENABLE_IPC_CORE) + hide_variable(HELICS_ENABLE_MPI_CORE) + hide_variable(HELICS_ENABLE_TRACE_LOGGING) + hide_variable(HELICS_ENABLE_PYTHON_BUILD_SCRIPTS) + hide_variable(HELICS_ENABLE_TEST_CORE) + hide_variable(HELICS_ENABLE_ZMQ_CORE) + hide_variable(HELICS_ENABLE_UDP_CORE) + hide_variable(HELICS_ENABLE_SUBMODULE_UPDATE) + hide_variable(HELICS_ENABLE_TCP_CORE) + hide_variable(HELICS_ENABLE_MPI_CORE) + + hide_variable(HELICS_USE_EXTERNAL_FMT) + hide_variable(HELICS_USE_EXTERNAL_JSONCPP) + hide_variable(HELICS_USE_EXTERNAL_SPDLOG) + hide_variable(HELICS_USE_EXTERNAL_UNITS) + hide_variable(HELICS_USE_POSITION_INDEPENDENT_CODE) + hide_variable(HELICS_USE_SYSTEM_ZEROMQ_ONLY) + hide_variable(HELICS_USE_ZMQ_STATIC_LIBRARY) + hide_variable(HELICS_ZMQ_FORCE_SUBPROJECT) + hide_variable(HELICS_ZMQ_SUBPROJECT) + endif() endif() # ------------------------------------------------------------- diff --git a/ThirdParty/concurrency b/ThirdParty/concurrency index 1ffdb2b7d9..1bed77b9a9 160000 --- a/ThirdParty/concurrency +++ b/ThirdParty/concurrency @@ -1 +1 @@ -Subproject commit 1ffdb2b7d9894d8dd4e3f284dff1a7052a785ac9 +Subproject commit 1bed77b9a976f46df964b27f589cc965600ee3cc diff --git a/appveyor.yml b/appveyor.yml index c8aebf3952..94ae5d604f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ branches: - main - develop -version: 3.3.0.{build} +version: 3.3.1.{build} image: Visual Studio 2019 diff --git a/config/cmake/AddGooglebenchmark.cmake b/config/cmake/AddGooglebenchmark.cmake index 705e1257e0..ac11e9c092 100644 --- a/config/cmake/AddGooglebenchmark.cmake +++ b/config/cmake/AddGooglebenchmark.cmake @@ -15,8 +15,7 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.11) include(FetchContent) fetchcontent_declare( - gbenchmark - GIT_REPOSITORY https://github.com/google/benchmark.git + gbenchmark GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG ${gbenchmark_version} ) @@ -54,13 +53,13 @@ endif() set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "") set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "Suppressing benchmark's tests") -set(BENCHMARK_ENABLE_INSTALL OFF CACHE INTERNAL "" ) +set(BENCHMARK_ENABLE_INSTALL OFF CACHE INTERNAL "") set(BENCHMARK_DOWNLOAD_DEPENDENCIES ON CACHE INTERNAL "") set(BENCHMARK_ENABLE_ASSEMBLY_TESTS OFF CACHE INTERNAL "") # tell google benchmarks to use std regex since we only compile on compilers with std regex -set(HAVE_STD_REGEX ON CACHE INTERNAL "" ) -set(HAVE_POSIX_REGEX OFF CACHE INTERNAL "" ) -set(HAVE_GNU_POSIX_REGEX OFF CACHE INTERNAL "" ) +set(HAVE_STD_REGEX ON CACHE INTERNAL "") +set(HAVE_POSIX_REGEX OFF CACHE INTERNAL "") +set(HAVE_GNU_POSIX_REGEX OFF CACHE INTERNAL "") add_subdirectory(${${gbName}_SOURCE_DIR} ${${gbName}_BINARY_DIR} EXCLUDE_FROM_ALL) # Target must already exist @@ -95,8 +94,6 @@ target_compile_options(benchmark_main PRIVATE $<$:/wd4244 target_compile_options(benchmark PRIVATE $<$:/wd4244 /wd4800>) if(MSVC) - target_compile_definitions(benchmark PUBLIC - _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) - target_compile_definitions(benchmark_main PUBLIC - _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) + target_compile_definitions(benchmark PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) + target_compile_definitions(benchmark_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) endif() diff --git a/config/cmake/AddGoogletest.cmake b/config/cmake/AddGoogletest.cmake index fa25f1c20e..11272f6f47 100644 --- a/config/cmake/AddGoogletest.cmake +++ b/config/cmake/AddGoogletest.cmake @@ -8,64 +8,50 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Downloads GTest and provides a helper macro to add tests. Add make check, as well, -# which gives output on failed tests without having to set an environment variable. +# Downloads GTest and provides a helper macro to add tests. Add make check, as well, which gives +# output on failed tests without having to set an environment variable. # set(gtest_version release-1.12.1) - string(TOLOWER "googletest" gtName) - include(FetchContent) - mark_as_advanced(FETCHCONTENT_BASE_DIR) - mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) - mark_as_advanced(FETCHCONTENT_QUIET) - mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) - - fetchcontent_declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG ${gtest_version} - GIT_SHALLOW 1 - UPDATE_COMMAND "" - ) - - fetchcontent_getproperties(googletest) +include(FetchContent) +mark_as_advanced(FETCHCONTENT_BASE_DIR) +mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) +mark_as_advanced(FETCHCONTENT_QUIET) +mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) + +fetchcontent_declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG ${gtest_version} + GIT_SHALLOW 1 + UPDATE_COMMAND "" +) - if(NOT ${gtName}_POPULATED) - # Fetch the content using previously declared details - fetchcontent_populate(googletest) +fetchcontent_getproperties(googletest) - endif() - hide_variable(FETCHCONTENT_SOURCE_DIR_GOOGLETEST) - hide_variable(FETCHCONTENT_UPDATES_DISCONNECTED_GOOGLETEST) +if(NOT ${gtName}_POPULATED) + # Fetch the content using previously declared details + fetchcontent_populate(googletest) +endif() +hide_variable(FETCHCONTENT_SOURCE_DIR_GOOGLETEST) +hide_variable(FETCHCONTENT_UPDATES_DISCONNECTED_GOOGLETEST) -set(gtest_force_shared_crt - ON - CACHE INTERNAL "" -) +set(gtest_force_shared_crt ON CACHE INTERNAL "") -set(BUILD_SHARED_LIBS - OFF - CACHE INTERNAL "" -) -set(HAVE_STD_REGEX - ON - CACHE INTERNAL "" -) +set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") +set(HAVE_STD_REGEX ON CACHE INTERNAL "") -set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS - 1 - CACHE INTERNAL "" -) +set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "") add_subdirectory(${${gtName}_SOURCE_DIR} ${${gtName}_BINARY_DIR} EXCLUDE_FROM_ALL) message(STATUS "loading google-test directory ${${gtName}_SOURCE_DIR}") if(NOT MSVC) - # target_Compile_options(gtest PRIVATE "-Wno-undef") target_Compile_options(gmock - # PRIVATE "-Wno-undef") target_Compile_options(gtest_main PRIVATE "-Wno-undef") + # target_Compile_options(gtest PRIVATE "-Wno-undef") target_Compile_options(gmock PRIVATE + # "-Wno-undef") target_Compile_options(gtest_main PRIVATE "-Wno-undef") # target_Compile_options(gmock_main PRIVATE "-Wno-undef") endif() @@ -78,11 +64,7 @@ macro(add_gtest TESTNAME) target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main) if(GOOGLE_TEST_INDIVIDUAL) - gtest_discover_tests( - ${TESTNAME} - TEST_PREFIX "${TESTNAME}." - PROPERTIES FOLDER "Tests" - ) + gtest_discover_tests(${TESTNAME} TEST_PREFIX "${TESTNAME}." PROPERTIES FOLDER "Tests") else() add_test(${TESTNAME} ${TESTNAME}) set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") @@ -104,11 +86,7 @@ set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES FOLDER "Exter if(MSVC) # add_compile_options( /wd4459) target_compile_definitions(gtest PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) - target_compile_definitions( - gtest_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) + target_compile_definitions(gtest_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) target_compile_definitions(gmock PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) - target_compile_definitions( - gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) + target_compile_definitions(gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) endif() diff --git a/config/cmake/BuildType.cmake b/config/cmake/BuildType.cmake index 6cf6017ce7..3aa28acfd2 100644 --- a/config/cmake/BuildType.cmake +++ b/config/cmake/BuildType.cmake @@ -11,22 +11,10 @@ set(default_build_type "Release") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message( - STATUS "Setting build type to '${default_build_type}' as none was specified." - ) - set( - CMAKE_BUILD_TYPE - "${default_build_type}" - CACHE STRING "Choose the type of build." FORCE - ) + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property( - CACHE CMAKE_BUILD_TYPE - PROPERTY - STRINGS - "Debug" - "Release" - "MinSizeRel" - "RelWithDebInfo" + CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" ) endif() diff --git a/config/cmake/CheckLatestCXXStandardOption.cmake b/config/cmake/CheckLatestCXXStandardOption.cmake index 3e5cf47a2e..ab06cf38da 100644 --- a/config/cmake/CheckLatestCXXStandardOption.cmake +++ b/config/cmake/CheckLatestCXXStandardOption.cmake @@ -10,16 +10,16 @@ include(CheckCXXCompilerFlag) if(NOT CMAKE_CXX_STANDARD) - if (${PROJECT_NAME}_CXX_STANDARD) + if(${PROJECT_NAME}_CXX_STANDARD) set(CMAKE_CXX_STANDARD ${PROJECT_NAME}_CXX_STANDARD) else() set(CMAKE_CXX_STANDARD 17) endif() endif() -if (CMAKE_CXX_STANDARD LESS 17) +if(CMAKE_CXX_STANDARD LESS 17) message(FATAL_ERROR "{$PROJECT_NAME} requires C++17 or greater") -endif () +endif() if(MSVC) if(CMAKE_CXX_STANDARD EQUAL 17) @@ -65,10 +65,10 @@ else() endif() endif() elseif(CMAKE_CXX_STANDARD EQUAL 17) - if (CYGWIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CYGWIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CXX_STANDARD_FLAG -std=gnu++17) else() - set(CXX_STANDARD_FLAG -std=c++17) + set(CXX_STANDARD_FLAG -std=c++17) endif() else() diff --git a/config/cmake/FindZeroMQ.cmake b/config/cmake/FindZeroMQ.cmake index 10e31eefda..a0d339e3d7 100644 --- a/config/cmake/FindZeroMQ.cmake +++ b/config/cmake/FindZeroMQ.cmake @@ -10,24 +10,22 @@ # # Find the ZeroMQ includes and library # -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~ # This module defines # ZeroMQ_INCLUDE_DIR, where to find zmq.h # ZeroMQ_LIBRARY, the library needed to use ZeroMQ # ZeroMQ_FOUND, if false, you cannot build anything that requires ZeroMQ. # ZeroMQ_SHARED_LIB the shared library that needs to be associated with the executable # adds targets for libzmq and libzmq-static -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~ set(ZeroMQ_FOUND 0) -set( - ZeroMQ_REGISTRY_PATH +set(ZeroMQ_REGISTRY_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ZeroMQ (x64);DisplayIcon]" ) -# this is to deal with something weird when specifying the install path from an external -# source +# this is to deal with something weird when specifying the install path from an external source if("${ZeroMQ_INSTALL_PATH}" STREQUAL "") set(ZeroMQ_PATH2 "") @@ -39,9 +37,7 @@ if(NOT ZeroMQ_LIBRARY_ONLY) find_path( ZeroMQ_ROOT_DIR NAMES include/zmq.h - HINTS - ${ZeroMQ_INCLUDE_PATH} ${ZeroMQ_REGISTRY_PATH} ${ZeroMQ_INSTALL_PATH} - ${ZeroMQ_PATH2} + HINTS ${ZeroMQ_INCLUDE_PATH} ${ZeroMQ_REGISTRY_PATH} ${ZeroMQ_INSTALL_PATH} ${ZeroMQ_PATH2} PATHS /usr /usr/local ) @@ -62,10 +58,8 @@ if(MSVC) # message(STATUS "toolset =${CMAKE_VS_PLATFORM_TOOLSET}") - if(${ZeroMQ_NAME} MATCHES "registry") # if key was not found, the string "registry" - # is returned - set( - _ZeroMQ_VERSIONS + if(${ZeroMQ_NAME} MATCHES "registry") # if key was not found, the string "registry" is returned + set(_ZeroMQ_VERSIONS "4_3_4" "4_3_3" "4_3_2" @@ -87,29 +81,20 @@ if(MSVC) ) set(ZeroMQ_LIBRARY_NAME) foreach(ver ${_ZeroMQ_VERSIONS}) - list( - APPEND - ZeroMQ_LIBRARY_NAME "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ver}" - ) + list(APPEND ZeroMQ_LIBRARY_NAME "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ver}") endforeach() foreach(ver ${_ZeroMQ_VERSIONS}) - list( - APPEND - ZeroMQ_DEBUG_LIBRARY_NAME - "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ver}" + list(APPEND ZeroMQ_DEBUG_LIBRARY_NAME + "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ver}" ) endforeach() else() # Format ZeroMQ library file name foreach(vs ${_VS_VERSIONS}) - set( - ZeroMQ_LIBRARY_NAME - "libzmq-v${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_NAME}" - ) + set(ZeroMQ_LIBRARY_NAME "libzmq-v${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_NAME}") endforeach() foreach(vs ${_VS_VERSIONS}) - set( - ZeroMQ_DEBUG_LIBRARY_NAME + set(ZeroMQ_DEBUG_LIBRARY_NAME "libzmq-v${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_NAME}" ) endforeach() @@ -119,12 +104,8 @@ endif() find_library( ZeroMQ_LIBRARY NAMES zmq libzmq ${ZeroMQ_LIBRARY_NAME} - HINTS - "${ZeroMQ_LIBRARY_PATH}" - "${ZeroMQ_ROOT_DIR}/lib" - "${ZeroMQ_INSTALL_PATH}/lib" - "${ZeroMQ_INSTALL_PATH}/bin" - ${ZeroMQ_PATH2}/lib + HINTS "${ZeroMQ_LIBRARY_PATH}" "${ZeroMQ_ROOT_DIR}/lib" "${ZeroMQ_INSTALL_PATH}/lib" + "${ZeroMQ_INSTALL_PATH}/bin" ${ZeroMQ_PATH2}/lib PATHS /lib /usr/lib /usr/local/lib ) @@ -132,12 +113,8 @@ if(MSVC) find_library( ZeroMQ_DEBUG_LIBRARY NAMES ${ZeroMQ_DEBUG_LIBRARY_NAME} - HINTS - "${ZeroMQ_LIBRARY_PATH}" - "${ZeroMQ_ROOT_DIR}/lib" - "${ZeroMQ_INSTALL_PATH}/lib" - "${ZeroMQ_INSTALL_PATH}/bin" - ${ZeroMQ_PATH2}/lib + HINTS "${ZeroMQ_LIBRARY_PATH}" "${ZeroMQ_ROOT_DIR}/lib" "${ZeroMQ_INSTALL_PATH}/lib" + "${ZeroMQ_INSTALL_PATH}/bin" ${ZeroMQ_PATH2}/lib PATHS /lib /usr/lib /usr/local/lib ) endif() @@ -145,28 +122,22 @@ endif() find_library( ZeroMQ_STATIC_LIBRARY NAMES zmq.a libzmq.a ${ZeroMQ_LIBRARY_NAME}.a - HINTS - "${ZeroMQ_LIBRARY_PATH}" - "${ZeroMQ_ROOT_DIR}/lib" - "${ZeroMQ_INSTALL_PATH}/lib" - "${ZeroMQ_INSTALL_PATH}/bin" - ${ZeroMQ_PATH2}/lib + HINTS "${ZeroMQ_LIBRARY_PATH}" "${ZeroMQ_ROOT_DIR}/lib" "${ZeroMQ_INSTALL_PATH}/lib" + "${ZeroMQ_INSTALL_PATH}/bin" ${ZeroMQ_PATH2}/lib PATHS /lib /usr/lib /usr/local/lib ) if(ZeroMQ_REQUIRE_HEADERS) if(ZeroMQ_INCLUDE_DIR) - if( - (ZeroMQ_LIBRARY AND NOT ZeroMQ_LIBRARY-NOTFOUND) - OR (ZeroMQ_STATIC_LIBRARY AND NOT ZeroMQ_STATIC_LIBRARY-NOTFOUND) + if((ZeroMQ_LIBRARY AND NOT ZeroMQ_LIBRARY-NOTFOUND) + OR (ZeroMQ_STATIC_LIBRARY AND NOT ZeroMQ_STATIC_LIBRARY-NOTFOUND) ) set(ZeroMQ_FOUND 1) endif() endif() else(ZeroMQ_REQUIRE_HEADERS) - if( - (ZeroMQ_LIBRARY AND NOT ZeroMQ_LIBRARY-NOTFOUND) - OR (ZeroMQ_STATIC_LIBRARY AND NOT ZeroMQ_STATIC_LIBRARY-NOTFOUND) + if((ZeroMQ_LIBRARY AND NOT ZeroMQ_LIBRARY-NOTFOUND) OR (ZeroMQ_STATIC_LIBRARY + AND NOT ZeroMQ_STATIC_LIBRARY-NOTFOUND) ) set(ZeroMQ_FOUND 1) endif() @@ -176,29 +147,21 @@ if(ZeroMQ_FOUND) # Create shared library target if(ZeroMQ_LIBRARY AND NOT ZeroMQ_LIBRARY-NOTFOUND) message(STATUS "Found ZeroMQ library: ${ZeroMQ_LIBRARY}") - # this is static because we are pointing to the library for the linker, not the - # shared object + # this is static because we are pointing to the library for the linker, not the shared + # object add_library(libzmq STATIC IMPORTED) if(ZeroMQ_DEBUG_LIBRARY) + set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION_RELEASE "${ZeroMQ_LIBRARY}") set_target_properties( - libzmq - PROPERTIES IMPORTED_LOCATION_RELEASE "${ZeroMQ_LIBRARY}" - ) - set_target_properties( - libzmq - PROPERTIES IMPORTED_LOCATION_DEBUG "${ZeroMQ_DEBUG_LIBRARY}" + libzmq PROPERTIES IMPORTED_LOCATION_DEBUG "${ZeroMQ_DEBUG_LIBRARY}" ) else(ZeroMQ_DEBUG_LIBRARY) - set_target_properties( - libzmq - PROPERTIES IMPORTED_LOCATION "${ZeroMQ_LIBRARY}" - ) + set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION "${ZeroMQ_LIBRARY}") endif(ZeroMQ_DEBUG_LIBRARY) if(ZeroMQ_INCLUDE_DIR) message(STATUS "Found ZeroMQ headers: ${ZeroMQ_INCLUDE_DIR}") set_target_properties( - libzmq - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}" + libzmq PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}" ) endif() else() @@ -213,14 +176,10 @@ if(ZeroMQ_FOUND) # Create static library target if(ZeroMQ_STATIC_LIBRARY AND NOT ZeroMQ_STATIC_LIBRARY-NOTFOUND) add_library(libzmq-static STATIC IMPORTED) - set_target_properties( - libzmq-static - PROPERTIES IMPORTED_LOCATION "${ZeroMQ_STATIC_LIBRARY}" - ) + set_target_properties(libzmq-static PROPERTIES IMPORTED_LOCATION "${ZeroMQ_STATIC_LIBRARY}") if(ZeroMQ_INCLUDE_DIR) set_target_properties( - libzmq-static - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}" + libzmq-static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}" ) endif() endif() @@ -228,9 +187,5 @@ endif() # show the variables only in the advanced view mark_as_advanced( - ZeroMQ_ROOT_DIR - ZeroMQ_INCLUDE_DIR - ZeroMQ_LIBRARY - ZeroMQ_STATIC_LIBRARY - ZeroMQ_FOUND + ZeroMQ_ROOT_DIR ZeroMQ_INCLUDE_DIR ZeroMQ_LIBRARY ZeroMQ_STATIC_LIBRARY ZeroMQ_FOUND ) diff --git a/config/cmake/addBoost.cmake b/config/cmake/addBoost.cmake index 01dfdd2d34..e091a9aee6 100644 --- a/config/cmake/addBoost.cmake +++ b/config/cmake/addBoost.cmake @@ -13,8 +13,7 @@ mark_as_advanced(BOOST_INSTALL_PATH) if(WIN32 AND NOT UNIX_LIKE) - set( - boost_versions + set(boost_versions boost_1_80_0 boost_1_79_0 boost_1_78_0 @@ -31,8 +30,7 @@ if(WIN32 AND NOT UNIX_LIKE) boost_1_67_0 ) - set( - poss_prefixes + set(poss_prefixes C: C:/local C:/boost @@ -92,11 +90,7 @@ endif() set(BOOST_MINIMUM_VERSION 1.67) if(BOOST_REQUIRED_LIBRARIES) - find_package( - Boost ${BOOST_MINIMUM_VERSION} - COMPONENTS ${BOOST_REQUIRED_LIBRARIES} - REQUIRED - ) + find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS ${BOOST_REQUIRED_LIBRARIES} REQUIRED) else() find_package(Boost ${BOOST_MINIMUM_VERSION}) endif() @@ -159,8 +153,8 @@ else() if(NOT TARGET Boostlibs::test) add_library(Boostlibs::test UNKNOWN IMPORTED) endif() - # if(MINGW) set_property(TARGET Boostlibs::core PROPERTY - # INTERFACE_COMPILE_DEFINTIONS BOOST_USE_WINDOWS_H) endif() + # if(MINGW) set_property(TARGET Boostlibs::core PROPERTY INTERFACE_COMPILE_DEFINTIONS + # BOOST_USE_WINDOWS_H) endif() endif() list(LENGTH Boost_LIBRARIES_core_debug core_debug_size) @@ -180,20 +174,15 @@ if(core_debug_size EQUAL 0) else() add_library(Boostlibs::${rand_name} UNKNOWN IMPORTED) endif() - set_target_properties( - Boostlibs::${rand_name} - PROPERTIES IMPORTED_LOCATION ${next_lib} - ) + set_target_properties(Boostlibs::${rand_name} PROPERTIES IMPORTED_LOCATION ${next_lib}) list(APPEND boost_core_deps Boostlibs::${rand_name}) endforeach() else() list(GET Boost_LIBRARIES_core_release 0 first_lib_r) list(GET Boost_LIBRARIES_core_debug 0 first_lib_d) set_target_properties( - Boostlibs::core - PROPERTIES - IMPORTED_LOCATION_DEBUG ${first_lib_d} IMPORTED_LOCATION_RELEASE - ${first_lib_r} + Boostlibs::core PROPERTIES IMPORTED_LOCATION_DEBUG ${first_lib_d} IMPORTED_LOCATION_RELEASE + ${first_lib_r} ) foreach(item RANGE 1 ${rng}) @@ -206,10 +195,8 @@ else() add_library(Boostlibs::${rand_name} UNKNOWN IMPORTED) endif() set_target_properties( - Boostlibs::${rand_name} - PROPERTIES - IMPORTED_LOCATION_DEBUG ${next_lib_d} IMPORTED_LOCATION_RELEASE - ${next_lib_r} + Boostlibs::${rand_name} PROPERTIES IMPORTED_LOCATION_DEBUG ${next_lib_d} + IMPORTED_LOCATION_RELEASE ${next_lib_r} ) list(APPEND boost_core_deps Boostlibs::${rand_name}) endforeach() @@ -217,29 +204,23 @@ endif() if(Boost_INCLUDE_DIR) set_target_properties( - Boostlibs::core Boostlibs::test - PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + Boostlibs::core Boostlibs::test PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + ${Boost_INCLUDE_DIR} ) endif() if(BOOST_REQUIRED_LIBRARIES) - set_target_properties( - Boostlibs::core - PROPERTIES INTERFACE_LINK_LIBRARIES "${boost_core_deps}" - ) + set_target_properties(Boostlibs::core PROPERTIES INTERFACE_LINK_LIBRARIES "${boost_core_deps}") if(Boost_LIBRARIES_test_debug) set_target_properties( - Boostlibs::test - PROPERTIES - IMPORTED_LOCATION_DEBUG "${Boost_LIBRARIES_test_debug}" - IMPORTED_LOCATION_RELEASE "${Boost_LIBRARIES_test_release}" + Boostlibs::test PROPERTIES IMPORTED_LOCATION_DEBUG "${Boost_LIBRARIES_test_debug}" + IMPORTED_LOCATION_RELEASE "${Boost_LIBRARIES_test_release}" ) else() set_target_properties( - Boostlibs::test - PROPERTIES IMPORTED_LOCATION "${Boost_LIBRARIES_test_release}" + Boostlibs::test PROPERTIES IMPORTED_LOCATION "${Boost_LIBRARIES_test_release}" ) endif() endif() -# message(STATUS "Using Boost core debug libraries : ${Boost_LIBRARIES_core_debug}") -# message(STATUS "Using Boost core release libraries : ${Boost_LIBRARIES_core_release}") +# message(STATUS "Using Boost core debug libraries : ${Boost_LIBRARIES_core_debug}") message(STATUS +# "Using Boost core release libraries : ${Boost_LIBRARIES_core_release}") diff --git a/config/cmake/addGitHooks.cmake b/config/cmake/addGitHooks.cmake index dbb075d3e7..3bc5883f15 100644 --- a/config/cmake/addGitHooks.cmake +++ b/config/cmake/addGitHooks.cmake @@ -12,78 +12,86 @@ set(CLANG_FORMAT_MIN_VERSION "7.0") function(set_git_hooks_enabled) execute_process( - COMMAND ${GIT_EXECUTABLE} config --local core.hooksPath .githooks - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND ${GIT_EXECUTABLE} config --local core.hooksPath .githooks + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) message(STATUS "Git hooks enabled") endfunction() function(set_git_hooks_disabled) execute_process( - COMMAND ${GIT_EXECUTABLE} config --local --unset core.hooksPath - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND ${GIT_EXECUTABLE} config --local --unset core.hooksPath + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) message(STATUS "Git hooks disabled") endfunction() -if (NOT DEFINED CLANG_FORMAT) +if(NOT DEFINED CLANG_FORMAT) find_program(CLANG_FORMAT clang-format) -endif () +endif() -if (CLANG_FORMAT) - execute_process(COMMAND ${CLANG_FORMAT} -version - OUTPUT_VARIABLE CLANG_FORMAT_VERSION - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -endif () +if(CLANG_FORMAT) + execute_process( + COMMAND ${CLANG_FORMAT} -version OUTPUT_VARIABLE CLANG_FORMAT_VERSION + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() -if (CLANG_FORMAT_VERSION MATCHES "^clang-format version .*") - string(REGEX - REPLACE "clang-format version ([.0-9]+).*" - "\\1" - CLANG_FORMAT_VERSION - "${CLANG_FORMAT_VERSION}") +if(CLANG_FORMAT_VERSION MATCHES "^clang-format version .*") + string(REGEX REPLACE "clang-format version ([.0-9]+).*" "\\1" CLANG_FORMAT_VERSION + "${CLANG_FORMAT_VERSION}" + ) - if (NOT CLANG_FORMAT_VERSION VERSION_LESS ${CLANG_FORMAT_MIN_VERSION}) + if(NOT CLANG_FORMAT_VERSION VERSION_LESS ${CLANG_FORMAT_MIN_VERSION}) set(CLANG_FORMAT_VERSION_OK ON) - endif () -else () + endif() +else() set(CLANG_FORMAT_VERSION_OK OFF) -endif () +endif() mark_as_advanced(CLANG_FORMAT) -if (HELICS_ENABLE_GIT_HOOKS AND NOT CLANG_FORMAT_VERSION_OK) - message(WARNING +if(HELICS_ENABLE_GIT_HOOKS AND NOT CLANG_FORMAT_VERSION_OK) + message( + WARNING "HELICS git hooks require clang-format version ${CLANG_FORMAT_MIN_VERSION} or higher.\n" "Install or update clang-format to use git hooks.\n" - "To select a different clang-format executable, update the CLANG_FORMAT property in CMake.") -endif () + "To select a different clang-format executable, update the CLANG_FORMAT property in CMake." + ) +endif() -if (EXISTS "${PROJECT_SOURCE_DIR}/.git") +if(EXISTS "${PROJECT_SOURCE_DIR}/.git") set(GIT_REPO_FOUND ON) -else () +else() set(GIT_REPO_FOUND OFF) -endif () +endif() -if (WIN32) - #there are a lot of potential issues doing this on windows, but the option should be available if desired - cmake_dependent_advanced_option(HELICS_ENABLE_GIT_HOOKS "Activate git hooks to run clang-format on committed files." OFF "GIT_REPO_FOUND;CLANG_FORMAT;CLANG_FORMAT_VERSION_OK" OFF) +if(WIN32) + # there are a lot of potential issues doing this on windows, but the option should be available + # if desired + cmake_dependent_advanced_option( + HELICS_ENABLE_GIT_HOOKS "Activate git hooks to run clang-format on committed files." OFF + "GIT_REPO_FOUND;CLANG_FORMAT;CLANG_FORMAT_VERSION_OK" OFF + ) else() - cmake_dependent_advanced_option(HELICS_ENABLE_GIT_HOOKS "Activate git hooks to run clang-format on committed files." ON "GIT_REPO_FOUND;CLANG_FORMAT;CLANG_FORMAT_VERSION_OK" OFF) + cmake_dependent_advanced_option( + HELICS_ENABLE_GIT_HOOKS "Activate git hooks to run clang-format on committed files." ON + "GIT_REPO_FOUND;CLANG_FORMAT;CLANG_FORMAT_VERSION_OK" OFF + ) endif() find_package(Git) -if (GIT_FOUND AND NOT GIT_VERSION_STRING VERSION_LESS "2.9") - if (HELICS_ENABLE_GIT_HOOKS AND GIT_REPO_FOUND) +if(GIT_FOUND AND NOT GIT_VERSION_STRING VERSION_LESS "2.9") + if(HELICS_ENABLE_GIT_HOOKS AND GIT_REPO_FOUND) set_git_hooks_enabled() - elseif (GIT_REPO_FOUND) + elseif(GIT_REPO_FOUND) set_git_hooks_disabled() else() message(STATUS "Directory is not a Git repository. Git hooks are disabled automatically.") - endif () -elseif (HELICS_ENABLE_GIT_HOOKS AND GIT_FOUND AND GIT_VERSION_STRING VERSION_LESS "2.9") + endif() +elseif(HELICS_ENABLE_GIT_HOOKS AND GIT_FOUND AND GIT_VERSION_STRING VERSION_LESS "2.9") message(WARNING "Git version earlier than 2.9 found, update Git to enable git hooks.") -elseif (HELICS_ENABLE_GIT_HOOKS AND NOT GIT_FOUND) +elseif(HELICS_ENABLE_GIT_HOOKS AND NOT GIT_FOUND) message(WARNING "Git not found, git hooks will not be enabled.") -endif () +endif() diff --git a/config/cmake/addJsoncpp.cmake b/config/cmake/addJsoncpp.cmake index 7b69ee99ca..6071ae406e 100644 --- a/config/cmake/addJsoncpp.cmake +++ b/config/cmake/addJsoncpp.cmake @@ -7,81 +7,89 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -option(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP "Use external copy of JsonCpp" OFF) -mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP) - -if(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP) - # NOTE: static jsoncpp should be built with CMAKE_POSITION_INDEPENDENT_CODE - find_package(jsoncpp REQUIRED) -else() - set(JSONCPP_WITH_TESTS OFF CACHE INTERNAL "") - set(JSONCPP_WITH_CMAKE_PACKAGE OFF CACHE INTERNAL "") - set(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE INTERNAL "") - set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF CACHE INTERNAL "") - set(JSONCPP_WITH_WARNING_AS_ERROR OFF CACHE INTERNAL "") - set(DEBUG_LIBNAME_SUFFIX ${CMAKE_DEBUG_POSTFIX} CACHE INTERNAL "") - - if(MSVC) - if(STATIC_STANDARD_LIB STREQUAL "default") - set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") - elseif(STATIC_STANDARD_LIB STREQUAL "static") - set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") - elseif(STATIC_STANDARD_LIB STREQUAL "dynamic") - set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") +if(NOT TARGET JsonCpp::JsonCpp) + option(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP "Use external copy of JsonCpp" OFF) + mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP) + + if(${PROJECT_NAME}_USE_EXTERNAL_JSONCPP) + # NOTE: static jsoncpp should be built with CMAKE_POSITION_INDEPENDENT_CODE + find_package(jsoncpp REQUIRED) + else() + set(JSONCPP_WITH_TESTS OFF CACHE INTERNAL "") + set(JSONCPP_WITH_CMAKE_PACKAGE OFF CACHE INTERNAL "") + set(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE INTERNAL "") + set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF CACHE INTERNAL "") + set(JSONCPP_WITH_WARNING_AS_ERROR OFF CACHE INTERNAL "") + set(DEBUG_LIBNAME_SUFFIX ${CMAKE_DEBUG_POSTFIX} CACHE INTERNAL "") + + if(MSVC) + if(STATIC_STANDARD_LIB STREQUAL "default") + set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") + elseif(STATIC_STANDARD_LIB STREQUAL "static") + set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") + elseif(STATIC_STANDARD_LIB STREQUAL "dynamic") + set(JSONCPP_STATIC_WINDOWS_RUNTIME OFF CACHE INTERNAL "") + endif() endif() - endif() - # so json cpp exports to the correct target export - set(INSTALL_EXPORT "" CACHE INTERNAL "") + # so json cpp exports to the correct target export + set(INSTALL_EXPORT "" CACHE INTERNAL "") - set(JSONCPP_DISABLE_CCACHE ON CACHE INTERNAL "") + set(JSONCPP_DISABLE_CCACHE ON CACHE INTERNAL "") - if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) # Supported values are ``17``, ``20``, and ``23``. - endif() + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) # Supported values are ``17``, ``20``, and ``23``. + endif() - if(BUILD_SHARED_LIBS) - set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) - set(BUILD_SHARED_LIBS OFF) - endif() + if(BUILD_SHARED_LIBS) + set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF) + endif() - if(BUILD_STATIC_LIBS) - set(OLD_BUILD_STATIC_LIBS ${BUILD_STATIC_LIBS}) - set(BUILD_STATIC_LIBS ON) - endif() + if(BUILD_STATIC_LIBS) + set(OLD_BUILD_STATIC_LIBS ${BUILD_STATIC_LIBS}) + set(BUILD_STATIC_LIBS ON) + endif() - if(BUILD_OBJECT_LIBS) - set(OLD_BUILD_OBJECT_LIBS ${BUILD_OBJECT_LIBS}) - set(BUILD_OBJECT_LIBS OFF) - endif() + if(BUILD_OBJECT_LIBS) + set(OLD_BUILD_OBJECT_LIBS ${BUILD_OBJECT_LIBS}) + set(BUILD_OBJECT_LIBS OFF) + endif() - # these are internal variables used in JSONCPP that we know to be true based on the - # requirements in HELICS for newer compilers than JSONCPP supports - set(HAVE_CLOCALE ON) - set(HAVE_LOCALECONV ON) - set(COMPILER_HAS_DEPRECATED ON) - set(HAVE_STDINT_H ON) - set(HAVE_DECIMAL_POINT ON) - add_subdirectory("${PROJECT_SOURCE_DIR}/ThirdParty/json_cpp" - "${PROJECT_BINARY_DIR}/ThirdParty/json_cpp" EXCLUDE_FROM_ALL) + # these are internal variables used in JSONCPP that we know to be true based on the + # requirements in HELICS for newer compilers than JSONCPP supports + set(HAVE_CLOCALE ON) + set(HAVE_LOCALECONV ON) + set(COMPILER_HAS_DEPRECATED ON) + set(HAVE_STDINT_H ON) + set(HAVE_DECIMAL_POINT ON) + add_subdirectory( + "${PROJECT_SOURCE_DIR}/ThirdParty/json_cpp" "${PROJECT_BINARY_DIR}/ThirdParty/json_cpp" + EXCLUDE_FROM_ALL + ) + + set_target_properties(jsoncpp_static PROPERTIES FOLDER Extern) + + if(OLD_BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS}) + endif() + if(OLD_BUILD_STATIC_LIBS) + set(BUILD_STATIC_LIBS ${OLD_BUILD_STATIC_LIBS}) + endif() - set_target_properties(jsoncpp_static PROPERTIES FOLDER Extern) + if(OLD_BUILD_OBJECT_LIBS) + set(BUILD_OBJECT_LIBS ${OLD_BUILD_OBJECT_LIBS}) + endif() - if(OLD_BUILD_SHARED_LIBS) - set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS}) - endif() + hide_variable(JSONCPP_WITH_STRICT_ISO) + hide_variable(DEBUG_LIBNAME_SUFFIX) + hide_variable(JSONCPP_USE_SECURE_MEMORY) + hide_variable(JSONCPP_WITH_EXAMPLE) - if(OLD_BUILD_STATIC_LIBS) - set(BUILD_STATIC_LIBS ${OLD_BUILD_STATIC_LIBS}) - endif() + if(NOT TARGET JsonCpp::JsonCpp AND TARGET jsoncpp_static) + add_library(JsonCpp::JsonCpp ALIAS jsoncpp_static) + endif() - if(OLD_BUILD_OBJECT_LIBS) - set(BUILD_OBJECT_LIBS ${OLD_BUILD_OBJECT_LIBS}) endif() - - hide_variable(JSONCPP_WITH_STRICT_ISO) - hide_variable(DEBUG_LIBNAME_SUFFIX) - hide_variable(JSONCPP_USE_SECURE_MEMORY) - hide_variable(JSONCPP_WITH_EXAMPLE) endif() diff --git a/config/cmake/addMPI.cmake b/config/cmake/addMPI.cmake index 98dd18da37..82fe9f6bf4 100644 --- a/config/cmake/addMPI.cmake +++ b/config/cmake/addMPI.cmake @@ -24,28 +24,16 @@ if(NOT MPI_C_FOUND) if(MSVC) # the cmake find MPI doesn't completely work for visual studio 2017 if(NOT MPI_CXX_COMPILER) - # message(STATUS "not mpi cxx compiler") For building MPI programs the - # selected Visual Studio compiler is used, namely cl.exe. So there is no - # need to set a specific MPI compiler. - set( - MPI_CXX_COMPILER - "${CMAKE_CXX_COMPILER}" - CACHE FILEPATH "Mpi CXX compiler" FORCE - ) - set( - MPI_C_COMPILER - "${CMAKE_C_COMPILER}" - CACHE FILEPATH "Mpi C compiler" FORCE - ) + # message(STATUS "not mpi cxx compiler") For building MPI programs the selected Visual + # Studio compiler is used, namely cl.exe. So there is no need to set a specific MPI + # compiler. + set(MPI_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "Mpi CXX compiler" FORCE) + set(MPI_C_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "Mpi C compiler" FORCE) endif(NOT MPI_CXX_COMPILER) if(MPIEXEC_EXECUTABLE) # if we found this then the target was found if(NOT MPI_C_LIBRARIES) if(MPI_msmpi_LIBRARY) - set( - MPI_C_LIBRARIES - ${MPI_msmpi_LIBRARY} - CACHE STRING "MPI C libraries" FORCE - ) + set(MPI_C_LIBRARIES ${MPI_msmpi_LIBRARY} CACHE STRING "MPI C libraries" FORCE) else() # TODO not sure how MPICH libraries are laid out on Windows endif() @@ -67,17 +55,13 @@ if(MPI_C_FOUND AND NOT TARGET MPI::MPI_C) set_property(TARGET MPI::MPI_C PROPERTY INTERFACE_LINK_LIBRARIES "") if(MPI_C_LIBRARIES) set_property( - TARGET MPI::MPI_C - APPEND - PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_C_LIBRARIES}" + TARGET MPI::MPI_C APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_C_LIBRARIES}" ) endif() if(MPI_C_LINK_FLAGS) string(STRIP "${MPI_C_LINK_FLAGS}" trimmed_mpi_c_flags) set_property( - TARGET MPI::MPI_C - APPEND - PROPERTY INTERFACE_LINK_LIBRARIES "${trimmed_mpi_c_flags}" + TARGET MPI::MPI_C APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${trimmed_mpi_c_flags}" ) endif() set_target_properties( @@ -87,12 +71,10 @@ if(MPI_C_FOUND AND NOT TARGET MPI::MPI_C) "${MPI_C_INCLUDE_DIR};${MPI_C_HEADER_DIR};${MPI_C_ADDITIONAL_INCLUDE_DIRS};${MPI_C_INCLUDE_PATH}" ) set_target_properties( - MPI::MPI_C - PROPERTIES INTERFACE_COMPILE_OPTIONS "${MPI_C_COMPILE_OPTIONS}" + MPI::MPI_C PROPERTIES INTERFACE_COMPILE_OPTIONS "${MPI_C_COMPILE_OPTIONS}" ) set_target_properties( - MPI::MPI_C - PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${MPI_C_COMPILE_DEFINITIONS}" + MPI::MPI_C PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${MPI_C_COMPILE_DEFINITIONS}" ) endif() if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX) @@ -100,17 +82,13 @@ if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX) set_property(TARGET MPI::MPI_CXX PROPERTY INTERFACE_LINK_LIBRARIES "") if(MPI_CXX_LIBRARIES) set_property( - TARGET MPI::MPI_CXX - APPEND - PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_CXX_LIBRARIES}" + TARGET MPI::MPI_CXX APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_CXX_LIBRARIES}" ) endif() if(MPI_CXX_LINK_FLAGS) string(STRIP "${MPI_CXX_LINK_FLAGS}" trimmed_mpi_cxx_flags) set_property( - TARGET MPI::MPI_CXX - APPEND - PROPERTY INTERFACE_LINK_LIBRARIES "${trimmed_mpi_cxx_flags}" + TARGET MPI::MPI_CXX APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${trimmed_mpi_cxx_flags}" ) endif() set_target_properties( @@ -120,12 +98,10 @@ if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX) "${MPI_CXX_INCLUDE_DIR};${MPI_CXX_HEADER_DIR};${MPI_CXX_ADDITIONAL_INCLUDE_DIRS};${MPI_CXX_INCLUDE_PATH}" ) set_target_properties( - MPI::MPI_CXX - PROPERTIES INTERFACE_COMPILE_OPTIONS "${MPI_CXX_COMPILE_OPTIONS}" + MPI::MPI_CXX PROPERTIES INTERFACE_COMPILE_OPTIONS "${MPI_CXX_COMPILE_OPTIONS}" ) set_target_properties( - MPI::MPI_CXX - PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${MPI_CXX_COMPILE_DEFINITIONS}" + MPI::MPI_CXX PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${MPI_CXX_COMPILE_DEFINITIONS}" ) endif() diff --git a/config/cmake/addNetworking.cmake b/config/cmake/addNetworking.cmake new file mode 100644 index 0000000000..75b0d08b6c --- /dev/null +++ b/config/cmake/addNetworking.cmake @@ -0,0 +1,44 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore +# National Security, LLC; Alliance for Sustainable Energy, LLC. +# See the top-level NOTICE for additional details. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +if(NOT TARGET gmlc::networking) + set(GMLC_NETWORKING_INSTALL OFF CACHE INTERNAL "") + set(GMLC_NETWORKING_ASIO_INCLUDE ${PROJECT_SOURCE_DIR}/ThirdParty/asio/asio/include) + set(GMLC_NETWORKING_CONCURRENCY_INCLUDE ${PROJECT_SOURCE_DIR}/ThirdParty/concurrency) + set(GMLC_NETWORKING_DISABLE_ASIO ${HELICS_DISABLE_ASIO} CACHE INTERNAL "") + + # hide some of the JSON in the networking library + set(JSON_CI OFF CACHE INTERNAL "") + set(JSON_Diagnostics OFF CACHE INTERNAL "") + set(JSON_ImplicitConversions ON CACHE INTERNAL "") + set(JSON_Install OFF CACHE INTERNAL "") + set(JSON_MultipleHeaders OFF CACHE INTERNAL "") + set(JSON_SystemInclude OFF CACHE INTERNAL "") + + if(HELICS_ENABLE_ENCRYPTION) + list(APPEND VCPKG_MANIFEST_FEATURES "encryption") + set(GMLC_NETWORKING_ENABLE_ENCRYPTION ON CACHE INTERNAL "") + else() + set(GMLC_NETWORKING_ENABLE_ENCRYPTION OFF CACHE INTERNAL "") + endif() + + add_subdirectory(ThirdParty/networking) + + hide_variable(GMLC_NETWORKING_GENERATE_DOXYGEN_DOC) + hide_variable(GMLC_NETWORKING_INCLUDE_BOOST) + hide_variable(GMLC_NETWORKING_WITH_CMAKE_PACKAGE) + hide_variable(GMLC_NETWORKING_OBJECT_LIB) + hide_variable(GMLC_NETWORKING_STATIC_LIB) + hide_variable(GMLC_NETWORKING_CLANG_TIDY_OPTIONS) + hide_variable(GMLC_NETWORKING_ENABLE_SUBMODULE_UPDATE) + hide_variable(GMLC_NETWORKING_USE_EXTERNAL_JSON) + + set_target_properties(gmlc_networking PROPERTIES FOLDER Extern) + +endif() diff --git a/config/cmake/addSpdlog.cmake b/config/cmake/addSpdlog.cmake index 3489662852..8ff49ce11a 100644 --- a/config/cmake/addSpdlog.cmake +++ b/config/cmake/addSpdlog.cmake @@ -11,45 +11,46 @@ # create the spdlog target # ----------------------------------------------------------------------------- -option(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG "Use external copy of spdlog" OFF) -mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG) +if(NOT TARGET spdlog::spdlog) + option(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG "Use external copy of spdlog" OFF) + mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG) -if(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG) - # find spdlog somewhere on the system - # NOTE/TODO: there may be odd corner cases when external spdlog depends on an - # external fmt, but we tell HELICS to use the vendored copy of fmt - # NOTE2: static spdlog should be built with CMAKE_POSITION_INDEPENDENT_CODE - find_package(spdlog REQUIRED) -else() - # the spdlog install internally stores whether it was built with this on - # our vendored copy of spdlog should never use its own fmt - set(SPDLOG_FMT_EXTERNAL ON CACHE INTERNAL "") + if(${PROJECT_NAME}_USE_EXTERNAL_SPDLOG) + # find spdlog somewhere on the system NOTE/TODO: there may be odd corner cases when external + # spdlog depends on an external fmt, but we tell HELICS to use the vendored copy of fmt + # NOTE2: static spdlog should be built with CMAKE_POSITION_INDEPENDENT_CODE + find_package(spdlog REQUIRED) + else() + # the spdlog install internally stores whether it was built with this on our vendored copy + # of spdlog should never use its own fmt + set(SPDLOG_FMT_EXTERNAL ON CACHE INTERNAL "") - # use the vendored SPDLOG library - add_subdirectory(ThirdParty/spdlog) + # use the vendored SPDLOG library + add_subdirectory(ThirdParty/spdlog) - set_target_properties(spdlog PROPERTIES FOLDER Extern) - hide_variable(SPDLOG_BUILD_ALL) - hide_variable(SPDLOG_BUILD_BENCH) - hide_variable(SPDLOG_BUILD_EXAMPLE) - hide_variable(SPDLOG_BUILD_EXAMPLE_HO) - hide_variable(SPDLOG_BUILD_SHARED) - hide_variable(SPDLOG_BUILD_TESTS) - hide_variable(SPDLOG_BUILD_TESTS_HO) - hide_variable(SPDLOG_BUILD_WARNINGS) - hide_variable(SPDLOG_ENABLE_PCH) - hide_variable(SPDLOG_NO_ATOMIC_LEVELS) - hide_variable(SPDLOG_NO_EXCEPTIONS) - hide_variable(SPDLOG_NO_THREAD_ID) - hide_variable(SPDLOG_NO_TLS) - hide_variable(SPDLOG_PREVENT_CHILD_FD) - hide_variable(SPDLOG_SANITIZE_ADDRESS) - hide_variable(SPDLOG_TIDY) - hide_variable(SPDLOG_WCHAR_FILENAMES) - hide_variable(SPDLOG_WCHAR_SUPPORT) - hide_variable(SPDLOG_DISABLE_DEFAULT_LOGGER) - hide_variable(SPDLOG_FMT_EXTERNAL_HO) - hide_variable(SPDLOG_INSTALL) - hide_variable(SPDLOG_CLOCK_COARSE) - hide_variable(SPDLOG_USE_STD_FORMAT) + set_target_properties(spdlog PROPERTIES FOLDER Extern) + hide_variable(SPDLOG_BUILD_ALL) + hide_variable(SPDLOG_BUILD_BENCH) + hide_variable(SPDLOG_BUILD_EXAMPLE) + hide_variable(SPDLOG_BUILD_EXAMPLE_HO) + hide_variable(SPDLOG_BUILD_SHARED) + hide_variable(SPDLOG_BUILD_TESTS) + hide_variable(SPDLOG_BUILD_TESTS_HO) + hide_variable(SPDLOG_BUILD_WARNINGS) + hide_variable(SPDLOG_ENABLE_PCH) + hide_variable(SPDLOG_NO_ATOMIC_LEVELS) + hide_variable(SPDLOG_NO_EXCEPTIONS) + hide_variable(SPDLOG_NO_THREAD_ID) + hide_variable(SPDLOG_NO_TLS) + hide_variable(SPDLOG_PREVENT_CHILD_FD) + hide_variable(SPDLOG_SANITIZE_ADDRESS) + hide_variable(SPDLOG_TIDY) + hide_variable(SPDLOG_WCHAR_FILENAMES) + hide_variable(SPDLOG_WCHAR_SUPPORT) + hide_variable(SPDLOG_DISABLE_DEFAULT_LOGGER) + hide_variable(SPDLOG_FMT_EXTERNAL_HO) + hide_variable(SPDLOG_INSTALL) + hide_variable(SPDLOG_CLOCK_COARSE) + hide_variable(SPDLOG_USE_STD_FORMAT) + endif() endif() diff --git a/config/cmake/addUnits.cmake b/config/cmake/addUnits.cmake index c0d24e133e..ce2671f5a7 100644 --- a/config/cmake/addUnits.cmake +++ b/config/cmake/addUnits.cmake @@ -7,34 +7,38 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -option(${PROJECT_NAME}_USE_EXTERNAL_UNITS "Use external copy of LLNL Units" OFF) -mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_UNITS) - -if(${PROJECT_NAME}_USE_EXTERNAL_UNITS) - # NOTE: static units should be built with CMAKE_POSITION_INDEPENDENT_CODE - find_package(units REQUIRED) -else() - # so units cpp exports to the correct target export - set(UNITS_INSTALL OFF CACHE INTERNAL "") - - if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) # Supported values are ``11``, ``14``, and ``17``. - endif() +if(NOT TARGET units::units) + + option(${PROJECT_NAME}_USE_EXTERNAL_UNITS "Use external copy of LLNL Units" OFF) + mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_UNITS) + + if(${PROJECT_NAME}_USE_EXTERNAL_UNITS) + # NOTE: static units should be built with CMAKE_POSITION_INDEPENDENT_CODE + find_package(units REQUIRED) + else() + # so units cpp exports to the correct target export + set(UNITS_INSTALL OFF CACHE INTERNAL "") - set(UNITS_BUILD_OBJECT_LIBRARY OFF CACHE INTERNAL "") - set(UNITS_BUILD_STATIC_LIBRARY ON CACHE INTERNAL "") - set(UNITS_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "") - set(UNITS_BUILD_CONVERTER_APP OFF CACHE INTERNAL "") - set(UNITS_BUILD_WEBSERVER OFF CACHE INTERNAL "") - set(UNITS_CLANG_TIDY_OPTIONS "" CACHE INTERNAL "") - set(UNITS_BUILD_FUZZ_TARGETS OFF CACHE INTERNAL "") + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) # Supported values are ``11``, ``14``, and ``17``. + endif() - add_subdirectory("${PROJECT_SOURCE_DIR}/ThirdParty/units" - "${PROJECT_BINARY_DIR}/ThirdParty/units") + set(UNITS_BUILD_OBJECT_LIBRARY OFF CACHE INTERNAL "") + set(UNITS_BUILD_STATIC_LIBRARY ON CACHE INTERNAL "") + set(UNITS_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "") + set(UNITS_BUILD_CONVERTER_APP OFF CACHE INTERNAL "") + set(UNITS_BUILD_WEBSERVER OFF CACHE INTERNAL "") + set(UNITS_CLANG_TIDY_OPTIONS "" CACHE INTERNAL "") + set(UNITS_BUILD_FUZZ_TARGETS OFF CACHE INTERNAL "") - set_target_properties(units PROPERTIES FOLDER Extern) + add_subdirectory( + "${PROJECT_SOURCE_DIR}/ThirdParty/units" "${PROJECT_BINARY_DIR}/ThirdParty/units" + ) - hide_variable(UNITS_HEADER_ONLY) - hide_variable(UNITS_BUILD_OBJECT_LIBRARY) - hide_variable(UNITS_NAMESPACE) + set_target_properties(units PROPERTIES FOLDER Extern) + + hide_variable(UNITS_HEADER_ONLY) + hide_variable(UNITS_BUILD_OBJECT_LIBRARY) + hide_variable(UNITS_NAMESPACE) + endif() endif() diff --git a/config/cmake/addUtilities.cmake b/config/cmake/addUtilities.cmake new file mode 100644 index 0000000000..a2d5a573e2 --- /dev/null +++ b/config/cmake/addUtilities.cmake @@ -0,0 +1,31 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore +# National Security, LLC; Alliance for Sustainable Energy, LLC. +# See the top-level NOTICE for additional details. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +if(NOT TARGET gmlc::utilities) + set(GMLC_UTILITIES_INSTALL OFF CACHE INTERNAL "") + + add_subdirectory(ThirdParty/utilities) + + hide_variable(GMLC_UTILITIES_GENERATE_DOXYGEN_DOC) + hide_variable(GMLC_UTILITIES_INCLUDE_BOOST) + hide_variable(GMLC_UTILITIES_USE_BOOST_SPIRIT) + hide_variable(GMLC_UTILITIES_WITH_CMAKE_PACKAGE) + hide_variable(GMLC_UTILITIES_OBJECT_LIB) + hide_variable(GMLC_UTILITIES_STATIC_LIB) + hide_variable(GMLC_UTILITIES_CLANG_TIDY_OPTIONS) + + target_compile_definitions(gmlc_utilities PUBLIC USE_STD_STRING_VIEW=1) + + set_target_properties(gmlc_utilities PROPERTIES FOLDER Extern) + if(NOT ${PROJECT_NAME}_DISABLE_BOOST) + target_include_directories( + gmlc_utilities SYSTEM PRIVATE $ + ) + endif() +endif() diff --git a/config/cmake/addZeroMQ.cmake b/config/cmake/addZeroMQ.cmake index 797f1a1f11..64a90d88ad 100644 --- a/config/cmake/addZeroMQ.cmake +++ b/config/cmake/addZeroMQ.cmake @@ -9,41 +9,36 @@ # file to include ZMQ option(${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY - "only search for system zeromq libraries, bypass local build options" OFF) + "only search for system zeromq libraries, bypass local build options" OFF +) mark_as_advanced(${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY) if(MSVC) cmake_dependent_option( ${PROJECT_NAME}_ZMQ_SUBPROJECT - "enable ZMQ to automatically download and include as a subproject" - ON - "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" - OFF + "enable ZMQ to automatically download and include as a subproject" ON + "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" OFF ) else() cmake_dependent_option( ${PROJECT_NAME}_ZMQ_SUBPROJECT - "enable ZMQ to automatically download and include as a subproject" - OFF - "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" - OFF + "enable ZMQ to automatically download and include as a subproject" OFF + "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" OFF ) endif() cmake_dependent_option( ${PROJECT_NAME}_ZMQ_FORCE_SUBPROJECT - "force ZMQ to automatically download and include as a subproject" - OFF - "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" - OFF + "force ZMQ to automatically download and include as a subproject" OFF + "NOT ${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY" OFF ) mark_as_advanced(${PROJECT_NAME}_USE_SYSTEM_ZEROMQ_ONLY) mark_as_advanced(${PROJECT_NAME}_ZMQ_SUBPROJECT) mark_as_advanced(${PROJECT_NAME}_ZMQ_FORCE_SUBPROJECT) -# Add option after seeing if only the static ZMQ library is available -# Using a macro so the option() command appears near other option() commands +# Add option after seeing if only the static ZMQ library is available Using a macro so the option() +# command appears near other option() commands macro(add_zmq_static_lib_option) if(ZeroMQ_STATIC_LIBRARY AND NOT ZeroMQ_LIBRARY) option(${PROJECT_NAME}_USE_ZMQ_STATIC_LIBRARY "use the ZMQ static library" ON) @@ -108,17 +103,15 @@ else() hide_variable(ZeroMQ_STATIC_LIBRARY) hide_variable(ZeroMQ_INCLUDE_DIR) else() - show_variable(ZeroMQ_DEBUG_LIBRARY FILEPATH - "path to the ZeroMQ debug library" "") + show_variable(ZeroMQ_DEBUG_LIBRARY FILEPATH "path to the ZeroMQ debug library" "") show_variable(ZeroMQ_LIBRARY FILEPATH "path to the ZeroMQ library" "") - show_variable(ZeroMQ_ROOT_DIR PATH "path to the ZeroMQ root directory" - "") + show_variable(ZeroMQ_ROOT_DIR PATH "path to the ZeroMQ root directory" "") if(${PROJECT_NAME}_USE_ZMQ_STATIC_LIBRARY) - show_variable(ZeroMQ_STATIC_LIBRARY FILEPATH - "path to the ZeroMQ static library" "") + show_variable( + ZeroMQ_STATIC_LIBRARY FILEPATH "path to the ZeroMQ static library" "" + ) endif() - show_variable(ZeroMQ_INCLUDE_DIR PATH - "path to the ZeroMQ include directory" "") + show_variable(ZeroMQ_INCLUDE_DIR PATH "path to the ZeroMQ include directory" "") endif() else() set(${PROJECT_NAME}_ZMQ_LOCAL_BUILD OFF CACHE INTERNAL "") @@ -132,10 +125,6 @@ add_zmq_static_lib_option() if(WIN32 AND NOT MSYS AND NOT CYGWIN) if(TARGET libzmq) - install( - FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT Runtime - ) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime) endif() endif() diff --git a/config/cmake/addfmt.cmake b/config/cmake/addfmt.cmake index 2a2763589d..b109d0af8f 100644 --- a/config/cmake/addfmt.cmake +++ b/config/cmake/addfmt.cmake @@ -13,46 +13,41 @@ option(${PROJECT_NAME}_USE_EXTERNAL_FMT "Use external copy of {fmt}" OFF) mark_as_advanced(${PROJECT_NAME}_USE_EXTERNAL_FMT) +if(NOT TARGET fmt::fmt) + if(${PROJECT_NAME}_USE_EXTERNAL_FMT) + # Note: static fmt should be built with CMAKE_POSITION_INDEPENDENT_CODE + find_package(fmt REQUIRED) + else() + set(FMT_SILENT ON) -if(${PROJECT_NAME}_USE_EXTERNAL_FMT) - # Note: static fmt should be built with CMAKE_POSITION_INDEPENDENT_CODE - find_package(fmt REQUIRED) -else() - set(FMT_SILENT ON) + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) # Supported values are ``17``, and ``20``. + endif() - if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) # Supported values are ``14``, and ``17``. - endif() + set(SUPPORTS_VARIADIC_TEMPLATES ON) + set(SUPPORTS_USER_DEFINED_LITERALS ON) + set(FMT_HAS_VARIANT ON) + set(type STRING CACHE INTERNAL "") - set(SUPPORTS_VARIADIC_TEMPLATES ON) - set(SUPPORTS_USER_DEFINED_LITERALS ON) - set(FMT_HAS_VARIANT ON) - set(type STRING CACHE INTERNAL "") + if(CYGWIN) + set(FMT_OS OFF CACHE INTERNAL "") + else() + set(FMT_OS ON CACHE INTERNAL "") + endif() + # add the vendored FMT header only library + add_subdirectory(ThirdParty/fmtlib) - if (CYGWIN) - set(FMT_OS - OFF - CACHE INTERNAL "" - ) - else() - set(FMT_OS - ON - CACHE INTERNAL "" - ) + set_target_properties(fmt PROPERTIES FOLDER Extern) + hide_variable(FMT_DOC) + hide_variable(FMT_INSTALL) + hide_variable(FMT_PEDANTIC) + hide_variable(FMT_TEST) + hide_variable(FMT_WERROR) + hide_variable(FMT_FUZZ) + hide_variable(FMT_CUDA_TEST) + hide_variable(FMT_DEBUG_POSTFIX) + hide_variable(FMT_INC_DIR) + hide_variable(FMT_MODULE) + hide_variable(FMT_SYSTEM_HEADERS) endif() - # add the vendored FMT header only library - add_subdirectory(ThirdParty/fmtlib) - - set_target_properties(fmt PROPERTIES FOLDER Extern) - hide_variable(FMT_DOC) - hide_variable(FMT_INSTALL) - hide_variable(FMT_PEDANTIC) - hide_variable(FMT_TEST) - hide_variable(FMT_WERROR) - hide_variable(FMT_FUZZ) - hide_variable(FMT_CUDA_TEST) - hide_variable(FMT_DEBUG_POSTFIX) - hide_variable(FMT_INC_DIR) - hide_variable(FMT_MODULE) - hide_variable(FMT_SYSTEM_HEADERS) endif() diff --git a/config/cmake/addlibzmq.cmake b/config/cmake/addlibzmq.cmake index 406120ad11..9f21c18865 100644 --- a/config/cmake/addlibzmq.cmake +++ b/config/cmake/addlibzmq.cmake @@ -19,151 +19,87 @@ else() set(zmq_shared_build ON) endif() - set(${PROJECT_NAME}_LIBZMQ_VERSION v4.3.4) - string(TOLOWER "libzmq" lcName) - include(FetchContent) +include(FetchContent) - mark_as_advanced(FETCHCONTENT_BASE_DIR) - mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) - mark_as_advanced(FETCHCONTENT_QUIET) - mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) +mark_as_advanced(FETCHCONTENT_BASE_DIR) +mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) +mark_as_advanced(FETCHCONTENT_QUIET) +mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) - fetchcontent_declare( - libzmq - GIT_REPOSITORY https://github.com/zeromq/libzmq.git - GIT_TAG ${${PROJECT_NAME}_LIBZMQ_VERSION} - ) +fetchcontent_declare( + libzmq GIT_REPOSITORY https://github.com/zeromq/libzmq.git + GIT_TAG ${${PROJECT_NAME}_LIBZMQ_VERSION} +) - fetchcontent_getproperties(libzmq) +fetchcontent_getproperties(libzmq) - if(NOT ${lcName}_POPULATED) - # Fetch the content using previously declared details - fetchcontent_populate(libzmq) +if(NOT ${lcName}_POPULATED) + # Fetch the content using previously declared details + fetchcontent_populate(libzmq) - endif() +endif() - hide_variable(FETCHCONTENT_SOURCE_DIR_LIBZMQ) - hide_variable(FETCHCONTENT_UPDATES_DISCONNECTED_LIBZMQ) +hide_variable(FETCHCONTENT_SOURCE_DIR_LIBZMQ) +hide_variable(FETCHCONTENT_UPDATES_DISCONNECTED_LIBZMQ) # Set custom variables, policies, etc. ... -set(ZMQ_BUILD_TESTS - OFF - CACHE INTERNAL "" -) -set(ENABLE_CURVE - OFF - CACHE INTERNAL "" -) -set(ENABLE_DRAFTS - OFF - CACHE INTERNAL "" -) -set(WITH_DOCS - OFF - CACHE INTERNAL "" -) -set(${PROJECT_NAME}_ZMQ_LOCAL_BUILD - ON - CACHE INTERNAL "" -) -set(LIBZMQ_PEDANTIC - OFF - CACHE INTERNAL "" -) -set(WITH_PERF_TOOL - OFF - CACHE INTERNAL "" -) -set(ENABLE_CPACK - OFF - CACHE INTERNAL "" -) -set(BUILD_STATIC - ${zmq_static_build} - CACHE INTERNAL "" -) -set(BUILD_SHARED - ${zmq_shared_build} - CACHE INTERNAL "" -) -set(ENABLE_CPACK - OFF - CACHE INTERNAL "" -) -set(ENABLE_WS - OFF - CACHE INTERNAL "" -) +set(ZMQ_BUILD_TESTS OFF CACHE INTERNAL "") +set(ENABLE_CURVE OFF CACHE INTERNAL "") +set(ENABLE_DRAFTS OFF CACHE INTERNAL "") +set(WITH_DOCS OFF CACHE INTERNAL "") +set(${PROJECT_NAME}_ZMQ_LOCAL_BUILD ON CACHE INTERNAL "") +set(LIBZMQ_PEDANTIC OFF CACHE INTERNAL "") +set(WITH_PERF_TOOL OFF CACHE INTERNAL "") +set(ENABLE_CPACK OFF CACHE INTERNAL "") +set(BUILD_STATIC ${zmq_static_build} CACHE INTERNAL "") +set(BUILD_SHARED ${zmq_shared_build} CACHE INTERNAL "") +set(ENABLE_CPACK OFF CACHE INTERNAL "") +set(ENABLE_WS OFF CACHE INTERNAL "") -set(ENABLE_PRECOMPILED - OFF - CACHE INTERNAL "" -) +set(ENABLE_PRECOMPILED OFF CACHE INTERNAL "") -set(ENABLE_CLANG - ON - CACHE INTERNAL "" -) +set(ENABLE_CLANG ON CACHE INTERNAL "") -set(ENABLE_TSAN - OFF - CACHE INTERNAL "" -) +set(ENABLE_TSAN OFF CACHE INTERNAL "") -set(ENABLE_TSAN - OFF - CACHE INTERNAL "" -) -if (${PROJECT_NAME}_ENABLE_ENCRYPTION AND NOT ${PROJECT_NAME}_DISABLE_ZMQ_ENCRYPTION) - set(WITH_LIBSODIUM - ON - CACHE INTERNAL "" -) +set(ENABLE_TSAN OFF CACHE INTERNAL "") +if(${PROJECT_NAME}_ENABLE_ENCRYPTION AND NOT ${PROJECT_NAME}_DISABLE_ZMQ_ENCRYPTION) + set(WITH_LIBSODIUM ON CACHE INTERNAL "") else() - set(WITH_LIBSODIUM - OFF - CACHE INTERNAL "" -) + set(WITH_LIBSODIUM OFF CACHE INTERNAL "") endif() -set(ZMQ_OUTPUT_BASENAME - zmq - CACHE INTERNAL "" -) +set(ZMQ_OUTPUT_BASENAME zmq CACHE INTERNAL "") -set(ZEROMQ_CMAKECONFIG_INSTALL_DIR - ${CMAKE_INSTALL_LIBDIR}/cmake/ZeroMQ - CACHE INTERNAL "" -) +set(ZEROMQ_CMAKECONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/ZeroMQ CACHE INTERNAL "") # Bring the populated content into the build set(COMPILER_SUPPORTS_CXX11 ON) set(ZMQ_HAVE_NOEXCEPT ON) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - message(STATUS "clang compiling for ZMQ ${CMAKE_CXX_FLAGS}") - set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-unused-parameter ") + message(STATUS "clang compiling for ZMQ ${CMAKE_CXX_FLAGS}") + set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-unused-parameter " + ) endif() add_subdirectory(${${lcName}_SOURCE_DIR} ${${lcName}_BINARY_DIR} EXCLUDE_FROM_ALL) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS ${OLDCMAKE_CXX_FLAGS}) + set(CMAKE_CXX_FLAGS ${OLDCMAKE_CXX_FLAGS}) endif() - set(ZeroMQ_FOUND TRUE) if(${PROJECT_NAME}_USE_ZMQ_STATIC_LIBRARY) set_target_properties(libzmq-static PROPERTIES FOLDER "Extern") - target_compile_options( - libzmq-static PRIVATE $<$>:-fPIC> - ) + target_compile_options(libzmq-static PRIVATE $<$>:-fPIC>) else() set_target_properties(libzmq PROPERTIES FOLDER "Extern") @@ -209,10 +145,8 @@ if(${PROJECT_NAME}_BUILD_CXX_SHARED_LIB OR NOT ${PROJECT_NAME}_DISABLE_C_SHARED_ FRAMEWORK DESTINATION "Library/Frameworks" ) elseif(WIN32) - install( - FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT libs + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT libs ) else() message( @@ -220,10 +154,7 @@ if(${PROJECT_NAME}_BUILD_CXX_SHARED_LIB OR NOT ${PROJECT_NAME}_DISABLE_C_SHARED_ "Update to CMake 3.13+ or enable the ${PROJECT_NAME}_USE_ZMQ_STATIC_LIBRARY CMake option to install when using ZMQ as a subproject" ) endif() - if(MSVC - AND NOT EMBEDDED_DEBUG_INFO - AND NOT ${PROJECT_NAME}_BINARY_ONLY_INSTALL - ) + if(MSVC AND NOT EMBEDDED_DEBUG_INFO AND NOT ${PROJECT_NAME}_BINARY_ONLY_INSTALL) install( FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -232,10 +163,8 @@ if(${PROJECT_NAME}_BUILD_CXX_SHARED_LIB OR NOT ${PROJECT_NAME}_DISABLE_C_SHARED_ ) endif() if(MSVC AND NOT ${PROJECT_NAME}_BINARY_ONLY_INSTALL) - install( - FILES $ - DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT libs + install(FILES $ + DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs ) endif() diff --git a/config/cmake/clang-cxx-dev-tools.cmake b/config/cmake/clang-cxx-dev-tools.cmake index 13640e6e9e..d341109f3a 100644 --- a/config/cmake/clang-cxx-dev-tools.cmake +++ b/config/cmake/clang-cxx-dev-tools.cmake @@ -10,12 +10,8 @@ file(GLOB ALL_APPLICATION_API_FILES src/helics/application_api/*.[ch]pp) file(GLOB ALL_APP_FILES src/helics/apps/*.[ch]pp) -file( - GLOB - ALL_SHARED_API_FILES - src/helics/shared_api_library/*.[ch]pp - src/helics/shared_api_library/*.[ch] - src/helics/shared_api_library/internal/*.h +file(GLOB ALL_SHARED_API_FILES src/helics/shared_api_library/*.[ch]pp + src/helics/shared_api_library/*.[ch] src/helics/shared_api_library/internal/*.h ) file( @@ -31,13 +27,11 @@ file( file(GLOB ALL_COMMON_FILES src/helics/common/*.[ch]pp) -set(ALL_APPLICATION_FILES ${ALL_APPLICATION_API_FILES} ${ALL_APP_FILES} - ${ALL_SHARED_API_FILES}) +set(ALL_APPLICATION_FILES ${ALL_APPLICATION_API_FILES} ${ALL_APP_FILES} ${ALL_SHARED_API_FILES}) set(ALL_CORE_FILES ${ALL_CORE_FILES} ${ALL_COMMON_FILES}) -set( - INCLUDE_DIRECTORIES +set(INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/src/helics/core ${PROJECT_SOURCE_DIR}/src/helics/application_api ${PROJECT_SOURCE_DIR}/src/helics/apps @@ -62,31 +56,21 @@ endforeach(f) # Adding clang-format target if executable is found find_program(CLANG_FORMAT "clang-format") if(CLANG_FORMAT) - add_custom_target( - clang-format-test - COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_TEST_FILES} - ) + add_custom_target(clang-format-test COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_TEST_FILES}) add_custom_target( - clang-format-application - COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_APPLICATION_FILES} + clang-format-application COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_APPLICATION_FILES} ) - add_custom_target( - clang-format-core - COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_CORE_FILES} - ) + add_custom_target(clang-format-core COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_CORE_FILES}) add_custom_target( - clang-format-examples - COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_EXAMPLE_FILES} + clang-format-examples COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_EXAMPLE_FILES} ) add_custom_target( - clang-format-all - DEPENDS - clang-format-test clang-format-application clang-format-core - clang-format-examples + clang-format-all DEPENDS clang-format-test clang-format-application clang-format-core + clang-format-examples ) endif() @@ -94,51 +78,26 @@ endif() find_program(CLANG_TIDY "clang-tidy") if(CLANG_TIDY) add_custom_target( - clang-tidy-test - COMMAND - ${CLANG_TIDY} - ${ALL_TEST_FILES} - -config='' - -- - -std=c++14 - ${INCLUDES} + clang-tidy-test COMMAND ${CLANG_TIDY} ${ALL_TEST_FILES} -config='' -- -std=c++14 + ${INCLUDES} ) add_custom_target( - clang-tidy-application - COMMAND - ${CLANG_TIDY} - ${ALL_APPLICATION_FILES} - -config='' - -- - -std=c++14 - ${INCLUDES} + clang-tidy-application COMMAND ${CLANG_TIDY} ${ALL_APPLICATION_FILES} -config='' -- + -std=c++14 ${INCLUDES} ) add_custom_target( - clang-tidy-core - COMMAND - ${CLANG_TIDY} - ${ALL_CORE_FILES} - -config='' - -- - -std=c++14 - ${INCLUDES} + clang-tidy-core COMMAND ${CLANG_TIDY} ${ALL_CORE_FILES} -config='' -- -std=c++14 + ${INCLUDES} ) add_custom_target( clang-tidy-ccore COMMAND - ${CLANG_TIDY} - ${PROJECT_SOURCE_DIR}/src/helics/core/CommonCore.cpp - ${PROJECT_SOURCE_DIR}/src/helics/core/CoreBroker.cpp - -config='' - -- - -std=c++14 + ${CLANG_TIDY} ${PROJECT_SOURCE_DIR}/src/helics/core/CommonCore.cpp + ${PROJECT_SOURCE_DIR}/src/helics/core/CoreBroker.cpp -config='' -- -std=c++14 ${INCLUDES} ) - add_custom_target( - clang-tidy-all - DEPENDS clang-tidy-test clang-tidy-application clang-tidy-core - ) + add_custom_target(clang-tidy-all DEPENDS clang-tidy-test clang-tidy-application clang-tidy-core) endif() diff --git a/config/cmake/combineLicenses.cmake b/config/cmake/combineLicenses.cmake index 6e6ace577d..4dcb4fb691 100644 --- a/config/cmake/combineLicenses.cmake +++ b/config/cmake/combineLicenses.cmake @@ -7,22 +7,14 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# takes a list of names and license file paths and combines the contents into a single -# file +# takes a list of names and license file paths and combines the contents into a single file function(combineLicenses OUT_FILE) file(WRITE "${OUT_FILE}.in" "Third-Party Licenses") list(LENGTH ARGN num_entries) math(EXPR end_entries "${num_entries}-1") - foreach( - entry - RANGE - 0 - ${end_entries} - 2 - ) - file( - APPEND "${OUT_FILE}.in" - "\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n" + foreach(entry RANGE 0 ${end_entries} 2) + file(APPEND "${OUT_FILE}.in" + "\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n" ) list(GET ARGN ${entry} entry_name) math(EXPR entry_file "${entry}+1") diff --git a/config/cmake/commonBuildFlags.cmake b/config/cmake/commonBuildFlags.cmake new file mode 100644 index 0000000000..0ca952a5a0 --- /dev/null +++ b/config/cmake/commonBuildFlags.cmake @@ -0,0 +1,68 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore +# National Security, LLC; Alliance for Sustainable Energy, LLC. +# See the top-level NOTICE for additional details. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# cmake script to set up build output directories + +include(ucm) + +# ----------------------------------------------------------------------------- +# General project wide configuration for debug postfix +# ----------------------------------------------------------------------------- +if(NOT NO_DEBUG_POSFIX AND NOT CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX d) +endif() + +if(NOT TARGET compile_flags_target) + add_library(compile_flags_target INTERFACE) +endif() + +if(NOT TARGET build_flags_target) + add_library(build_flags_target INTERFACE) +endif() + +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + mark_as_advanced(BUILD_TESTING) + include(compiler_flags) + +endif() + +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + if(NOT USE_LIBCXX) + show_variable(STATIC_STANDARD_LIB STRING "Link against a static standard lib" default) + set_property(CACHE STATIC_STANDARD_LIB PROPERTY STRINGS default static dynamic) + else() + hide_variable(STATIC_STANDARD_LIB) + endif() + if(MSVC) + show_variable( + ${PROJECT_NAME}_EMBEDDED_DEBUG_INFO STRING "embed debug info into lib files" default + ) + set_property( + CACHE ${PROJECT_NAME}_EMBEDDED_DEBUG_INFO PROPERTY STRINGS default embedded external + ) + else() + hide_variable(${PROJECT_NAME}_EMBEDDED_DEBUG_INFO) + endif() +endif() + +if(STATIC_STANDARD_LIB STREQUAL "default") + +elseif(STATIC_STANDARD_LIB STREQUAL "static") + ucm_set_runtime(STATIC) +elseif(STATIC_STANDARD_LIB STREQUAL "dynamic") + ucm_set_runtime(DYNAMIC) +endif() + +if(${PROJECT_NAME}_EMBEDDED_DEBUG_INFO STREQUAL "default") + +elseif(${PROJECT_NAME}_EMBEDDED_DEBUG_INFO STREQUAL "external") + ucm_set_embedded_debug(EXTERNAL) +else() + ucm_set_embedded_debug(EMBEDDED) +endif() diff --git a/config/cmake/commonBuildPaths.cmake b/config/cmake/commonBuildPaths.cmake new file mode 100644 index 0000000000..e56137184b --- /dev/null +++ b/config/cmake/commonBuildPaths.cmake @@ -0,0 +1,99 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore +# National Security, LLC; Alliance for Sustainable Energy, LLC. +# See the top-level NOTICE for additional details. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# cmake script to set up build output directories + +# ----------------------------------------------------------------------------- +# set the install path to a local directory +# ----------------------------------------------------------------------------- +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + if(WIN32) + if(MSVC) + set(CMAKE_INSTALL_PREFIX "C:/local/helics_${HELICS_VERSION_UNDERSCORE}/" + CACHE PATH "default install path" FORCE + ) + elseif(MINGW AND NOT MSYS) + set(CMAKE_INSTALL_PREFIX "C:/local/helics_${HELICS_VERSION_UNDERSCORE}/" + CACHE PATH "default install path" FORCE + ) + elseif(MSYS) + # use CMAKE_OBJCOPY here since it is somewhat less likely to be overridden by users + # rather than the compiler + get_filename_component(path_bin ${CMAKE_OBJCOPY} DIRECTORY) + get_filename_component(path_install ${path_bin} DIRECTORY) + set(CMAKE_INSTALL_PREFIX ${path_install} CACHE PATH "default install path" FORCE) + endif(MSVC) + endif(WIN32) +endif() + +# Warning if CMAKE_INSTALL_PREFIX is empty. Likely set by using the wrong environment variable. +if(NOT CMAKE_INSTALL_PREFIX) + message( + WARNING + "CMAKE_INSTALL_PREFIX is set to nothing. If you are using an environment variable for handling prefix paths, that variable might not have been set before using it with CMake to set the CMAKE_INSTALL_PREFIX option." + ) +endif() + +# Check to make sure the install prefix isn't the build folder, if it is, build errors will happen +get_filename_component(tmp_install_prefix "${CMAKE_INSTALL_PREFIX}" REALPATH) +get_filename_component(tmp_proj_bindir "${PROJECT_BINARY_DIR}" REALPATH) +# Windows paths are case insensitive +if(WIN32) + string(TOLOWER "${tmp_install_prefix}" tmp_install_prefix) + string(TOLOWER "${tmp_proj_bindir}" tmp_proj_bindir) +endif() +if(tmp_install_prefix STREQUAL tmp_proj_bindir) + message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must not be set to the build folder") +endif() + +if(MSYS + OR CYGWIN + OR UNIX + OR APPLE +) + set(UNIX_LIKE TRUE) +endif() + +# Set the build output paths +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH + "Archive output dir." + ) + endif() + if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH + "Library output dir." + ) + endif() + if(NOT CMAKE_PDB_OUTPUT_DIRECTORY) + set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + CACHE PATH "PDB (MSVC debug symbol)output dir." + ) + endif() + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + CACHE PATH "Executable/dll output dir." + ) + endif() +endif() + +# Prohibit in-source build +if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + if(EXISTS "${PROJECT_SOURCE_DIR}/CMakeCache.txt") + message( + WARNING + "The source directory ${PROJECT_SOURCE_DIR} contains CMakeCache.txt and possibly other cmake folders like CMakeFiles that might interfere with the current build" + ) + endif() + message( + FATAL_ERROR + "In-source build is not supported. Please, use an empty directory for building the project." + ) +endif() diff --git a/config/cmake/commonRPath.cmake b/config/cmake/commonRPath.cmake new file mode 100644 index 0000000000..addadd1676 --- /dev/null +++ b/config/cmake/commonRPath.cmake @@ -0,0 +1,49 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore +# National Security, LLC; Alliance for Sustainable Energy, LLC. +# See the top-level NOTICE for additional details. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# setup common rpath configuration + +# ------------------------------------------------------------- +# setting the RPATH +# ------------------------------------------------------------- +if(NOT DEFINED CMAKE_MACOSX_RPATH) + set(CMAKE_MACOSX_RPATH ON) +endif() + +# add the automatically determined parts of the RPATH which point to directories outside the build +# tree to the install RPATH +if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + +# Add the local directory to the rpath +if(NOT APPLE) + list(APPEND CMAKE_INSTALL_RPATH $ORIGIN) + list(APPEND CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") +else() + list(APPEND CMAKE_INSTALL_RPATH "@loader_path") + list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") + list(APPEND CMAKE_INSTALL_RPATH "@executable_path") + list(APPEND CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") +endif() + +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" isSystemDir +) +if(isSystemDir STREQUAL "-1") + list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") +endif() + +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir +) +if(isSystemDir STREQUAL "-1") + list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +endif() diff --git a/config/cmake/compiler_flags.cmake b/config/cmake/compiler_flags.cmake index 5238cfe66f..a910bc37c6 100644 --- a/config/cmake/compiler_flags.cmake +++ b/config/cmake/compiler_flags.cmake @@ -7,8 +7,8 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include(CMakeDependentOption) -if (WIN32) -# from https://stackoverflow.com/a/40217291/2019765 by squareskittles +if(WIN32) + # from https://stackoverflow.com/a/40217291/2019765 by squareskittles macro(get_WIN32_WINNT version) if(CMAKE_SYSTEM_VERSION) set(ver ${CMAKE_SYSTEM_VERSION}) @@ -28,14 +28,19 @@ if (WIN32) endmacro(get_WIN32_WINNT) endif() +cmake_dependent_option( + ${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS + "disable compiler warning for ${CMAKE_PROJECT_NAME} build" ON + "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF +) -cmake_dependent_option(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS - "disable compiler warning for ${CMAKE_PROJECT_NAME} build" ON "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF) - -cmake_dependent_option(${PROJECT_NAME}_ENABLE_ERROR_ON_WARNINGS - "generate a compiler error for any warning encountered" OFF "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF) +cmake_dependent_option( + ${PROJECT_NAME}_ENABLE_ERROR_ON_WARNINGS + "generate a compiler error for any warning encountered" OFF + "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF +) -if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) mark_as_advanced(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) mark_as_advanced(${PROJECT_NAME}_ENABLE_ERROR_ON_WARNINGS) endif() @@ -43,15 +48,15 @@ endif() # ------------------------------------------------------------- # Setup compiler options and configurations # ------------------------------------------------------------- -if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - message(STATUS "setting up for ${CMAKE_CXX_COMPILER_ID} on ${CMAKE_SYSTEM}") +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + message(STATUS "setting up for ${CMAKE_CXX_COMPILER_ID} on ${CMAKE_SYSTEM}") endif() if(NOT TARGET compile_flags_target) add_library(compile_flags_target INTERFACE) endif() -if (NOT TARGET build_flags_target) +if(NOT TARGET build_flags_target) add_library(build_flags_target INTERFACE) endif() @@ -62,31 +67,18 @@ target_compile_options( $<$>:$<$:-Werror>> ) -target_compile_options( - compile_flags_target - INTERFACE - ${${PROJECT_NAME}_EXTRA_COMPILE_FLAGS} -) +target_compile_options(compile_flags_target INTERFACE ${${PROJECT_NAME}_EXTRA_COMPILE_FLAGS}) -target_compile_options( - build_flags_target - INTERFACE - ${${PROJECT_NAME}_EXTRA_BUILD_FLAGS} -) +target_compile_options(build_flags_target INTERFACE ${${PROJECT_NAME}_EXTRA_BUILD_FLAGS}) if(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) target_compile_options( - compile_flags_target - INTERFACE $<$>:-Wall -pedantic> + compile_flags_target INTERFACE $<$>:-Wall -pedantic> ) target_compile_options( compile_flags_target - INTERFACE - $<$:$<$>:-Wextra - -Wstrict-aliasing=1 - -Wunreachable-code - -Woverloaded-virtual - -Wundef>> + INTERFACE $<$:$<$>:-Wextra + -Wstrict-aliasing=1 -Wunreachable-code -Woverloaded-virtual -Wundef>> ) target_compile_options( @@ -98,48 +90,45 @@ if(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) INTERFACE $<$:$<$:-Wcast-align -Wlogical-op>> ) # target_compile_options(compile_flags_target INTERFACE - # $<$:-Wredundant-decls>) - # target_compile_options(compile_flags_target INTERFACE - # $<$:-Wstrict-overflow=5>) - + # $<$:-Wredundant-decls>) target_compile_options(compile_flags_target + # INTERFACE $<$:-Wstrict-overflow=5>) # this option produces a number of warnings in third party libraries # target_compile_options(compile_flags_target INTERFACE - # $<$:$<$:-Wold-style-cast>>) this - # options produces lots of warning but is useful for checking every once in a while - # with Clang, GCC warning notices with this aren't as useful - # target_compile_options(compile_flags_target INTERFACE - # $<$:-Wpadded>) add some gnu specific options if the compiler - # is newer + # $<$:$<$:-Wold-style-cast>>) this options produces + # lots of warning but is useful for checking every once in a while with Clang, GCC warning + # notices with this aren't as useful target_compile_options(compile_flags_target INTERFACE + # $<$:-Wpadded>) add some gnu specific options if the compiler is newer if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # this option produces a number of warnings in third party libraries but useful - # for checking for any internal usages - target_compile_options( - compile_flags_target - INTERFACE - $<$:-Wduplicated-cond -Wclass-memaccess -Wnull-dereference -Wshadow -Wimplicit-fallthrough=2 -Wno-psabi -Wno-deprecated-declarations> - ) + # this option produces a number of warnings in third party libraries but useful for checking + # for any internal usages + target_compile_options( + compile_flags_target + INTERFACE $<$:-Wduplicated-cond + -Wclass-memaccess + -Wnull-dereference + -Wshadow + -Wimplicit-fallthrough=2 + -Wno-psabi + -Wno-deprecated-declarations> + ) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) target_link_libraries(build_flags_target INTERFACE "stdc++fs") endif() endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(compile_flags_target INTERFACE $<$:-Wshadow>) target_compile_options( - compile_flags_target - INTERFACE $<$:-Wshadow> - ) + compile_flags_target INTERFACE -Wdocumentation -Wno-documentation-deprecated-sync + ) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0) + message(STATUS "clang>13") target_compile_options( - compile_flags_target - INTERFACE -Wdocumentation -Wno-documentation-deprecated-sync + compile_flags_target INTERFACE -Wreserved-identifier -Wunused-but-set-parameter + -Wunused-but-set-variable ) - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0) - message(STATUS "clang>13") - target_compile_options( - compile_flags_target - INTERFACE -Wreserved-identifier -Wunused-but-set-parameter -Wunused-but-set-variable - ) - endif () + endif() endif() endif(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) @@ -148,8 +137,7 @@ endif(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) # ------------------------------------------------------------- if(MSVC) target_compile_options( - compile_flags_target - INTERFACE -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /MP + compile_flags_target INTERFACE -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /MP ) # these next two should be global @@ -157,17 +145,26 @@ if(MSVC) target_compile_options(build_flags_target INTERFACE /EHsc) if(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) - target_compile_options(compile_flags_target INTERFACE /W4 /sdl /wd4244 /wd4503 /wd4592 /wd4455) + target_compile_options( + compile_flags_target + INTERFACE /W4 + /sdl + /wd4244 + /wd4503 + /wd4592 + /wd4455 + ) endif(${PROJECT_NAME}_ENABLE_EXTRA_COMPILER_WARNINGS) get_win32_winnt(COPTION_WIN32_WINNT_DEFAULT) - target_compile_options(compile_flags_target INTERFACE "-D_WIN32_WINNT=${COPTION_WIN32_WINNT_DEFAULT}") + target_compile_options( + compile_flags_target INTERFACE "-D_WIN32_WINNT=${COPTION_WIN32_WINNT_DEFAULT}" + ) message( - STATUS - "Detected _WIN32_WINNT from CMAKE_SYSTEM_VERSION: ${COPTION_WIN32_WINNT_DEFAULT}" + STATUS "Detected _WIN32_WINNT from CMAKE_SYSTEM_VERSION: ${COPTION_WIN32_WINNT_DEFAULT}" ) if(CMAKE_SIZEOF_VOID_P EQUAL 4) - # disable some irrelevant integer overflow warnings on 32 bit systems - target_compile_options(compile_flags_target INTERFACE /wd4307 /wd4309) + # disable some irrelevant integer overflow warnings on 32 bit systems + target_compile_options(compile_flags_target INTERFACE /wd4307 /wd4309) endif() else(MSVC) option(USE_LIBCXX "Use Libc++ vs as opposed to the default" OFF) @@ -177,20 +174,22 @@ else(MSVC) add_compile_options($<$:-stdlib=libc++>) link_libraries("-stdlib=libc++") link_libraries("c++abi") - target_compile_options(build_flags_target INTERFACE $<$:-stdlib=libc++>) + target_compile_options( + build_flags_target INTERFACE $<$:-stdlib=libc++> + ) target_link_libraries(build_flags_target INTERFACE "-stdlib=libc++") target_link_libraries(build_flags_target INTERFACE "c++abi") endif(USE_LIBCXX) endif() -## remove potential duplicates from the flags +# remove potential duplicates from the flags get_target_property(compile_flags_list compile_flags_target INTERFACE_COMPILE_OPTIONS) list(REMOVE_DUPLICATES compile_flags_list) set_property(TARGET compile_flags_target PROPERTY INTERFACE_COMPILE_OPTIONS ${compile_flags_list}) get_target_property(link_flags_list compile_flags_target INTERFACE_LINK_OPTIONS) -if (link_flags_list) +if(link_flags_list) list(REMOVE_DUPLICATES link_flags_list) set_property(TARGET compile_flags_target PROPERTY INTERFACE_LINK_OPTIONS ${link_flags_list}) endif() @@ -200,23 +199,20 @@ endif() # ------------------------------------------------------------- include(CheckLatestCXXStandardOption) -message( - STATUS "setting helics C++ standard build option to \"${CXX_STANDARD_FLAG}\"" - ) +message(STATUS "setting helics C++ standard build option to \"${CXX_STANDARD_FLAG}\"") if(CXX_STANDARD_FLAG) - if(MSVC) - add_compile_options(${CXX_STANDARD_FLAG}) - target_compile_options(build_flags_target INTERFACE ${CXX_STANDARD_FLAG}) - else(MSVC) - add_compile_options($<$:${CXX_STANDARD_FLAG}>) - target_compile_options( - build_flags_target - INTERFACE $<$:${CXX_STANDARD_FLAG}> - ) - endif(MSVC) + if(MSVC) + add_compile_options(${CXX_STANDARD_FLAG}) + target_compile_options(build_flags_target INTERFACE ${CXX_STANDARD_FLAG}) + else(MSVC) + add_compile_options($<$:${CXX_STANDARD_FLAG}>) + target_compile_options( + build_flags_target INTERFACE $<$:${CXX_STANDARD_FLAG}> + ) + endif(MSVC) endif(CXX_STANDARD_FLAG) -## remove potential duplicates from the flags +# remove potential duplicates from the flags get_target_property(build_flags_list build_flags_target INTERFACE_COMPILE_OPTIONS) list(REMOVE_DUPLICATES build_flags_list) set_property(TARGET build_flags_target PROPERTY INTERFACE_COMPILE_OPTIONS ${build_flags_list}) diff --git a/config/cmake/copy_key_files.cmake b/config/cmake/copy_key_files.cmake index 0b23137931..3bd5d7fb5d 100644 --- a/config/cmake/copy_key_files.cmake +++ b/config/cmake/copy_key_files.cmake @@ -12,7 +12,8 @@ macro(copy_key_files_to_target_location target) foreach(keyfile IN LISTS KEY_LIBRARY_FILES) add_custom_command( - TARGET ${target} POST_BUILD # Adds a post-build event to api tests + TARGET ${target} + POST_BUILD # Adds a post-build event to api tests COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E # copy_if_different..." @@ -24,7 +25,8 @@ macro(copy_key_files_to_target_location target) if(TARGET libzmq) add_custom_command( - TARGET ${target} POST_BUILD # Adds a post-build event to core tests + TARGET ${target} + POST_BUILD # Adds a post-build event to core tests COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E # copy_if_different..." @@ -38,34 +40,22 @@ endmacro() macro(copy_shared_target target shared_target) add_custom_command( - TARGET ${target} POST_BUILD # Adds a post-build event to api tests + TARGET ${target} + POST_BUILD # Adds a post-build event to api tests COMMAND - ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E - # copy_if_different..." + ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." "$" # <--this is in- file "$/" ) # <--this is out- file path endmacro() macro(install_key_files_with_comp comp) - install( - FILES $ - DESTINATION ${comp} - COMPONENT ${comp} - ) - install( - FILES ${KEY_LIBRARY_FILES} - DESTINATION ${comp} - COMPONENT ${comp} - ) + install(FILES $ DESTINATION ${comp} COMPONENT ${comp}) + install(FILES ${KEY_LIBRARY_FILES} DESTINATION ${comp} COMPONENT ${comp}) if(WIN32) if(TARGET libzmq) - install( - FILES $ - DESTINATION ${comp} - COMPONENT ${comp} - ) + install(FILES $ DESTINATION ${comp} COMPONENT ${comp}) endif() endif(WIN32) diff --git a/config/cmake/escape_string.cmake b/config/cmake/escape_string.cmake index 14aabcd37a..9a8773c462 100644 --- a/config/cmake/escape_string.cmake +++ b/config/cmake/escape_string.cmake @@ -16,8 +16,8 @@ function(escape_string outstring instring) # string(REGEX REPLACE ";" "\\\\;" ${outstring} ${outstring}) string(REGEX REPLACE " " "\\\\ " OUT_STRING_TEMP ${OUT_STRING_TEMP}) - # string(REGEX REPLACE "\\\"" "\\\\"" OUT_STRING_TEMP ${OUT_STRING_TEMP}) - # message(STATUS "${OUT_STRING_TEMP} :: ${instring}") + # string(REGEX REPLACE "\\\"" "\\\\"" OUT_STRING_TEMP ${OUT_STRING_TEMP}) message(STATUS + # "${OUT_STRING_TEMP} :: ${instring}") # message(STATUS "${${outstring}}") diff --git a/config/cmake/extraMacros.cmake b/config/cmake/extraMacros.cmake index eb620749c4..168763c575 100644 --- a/config/cmake/extraMacros.cmake +++ b/config/cmake/extraMacros.cmake @@ -1,5 +1,5 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Copyright (c) 2017-2020, Battelle Memorial Institute; Lawrence Livermore +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore # National Security, LLC; Alliance for Sustainable Energy, LLC. # See the top-level NOTICE for additional details. # All rights reserved. @@ -11,10 +11,9 @@ # MACRO definitions # ------------------------------------------------------------- -# Macros to hide/show cached variables. These two macros can be used to "hide" or "show" -# in the list of cached variables various variables and/or options that depend on other -# options. Note that once a variable is modified, it will preserve its value (hiding it -# merely makes it internal) +# Macros to hide/show cached variables. These two macros can be used to "hide" or "show" in the list +# of cached variables various variables and/or options that depend on other options. Note that once +# a variable is modified, it will preserve its value (hiding it merely makes it internal) macro(HIDE_VARIABLE var) if(DEFINED ${var}) @@ -22,13 +21,7 @@ macro(HIDE_VARIABLE var) endif(DEFINED ${var}) endmacro(HIDE_VARIABLE) -macro( - SHOW_VARIABLE - var - type - doc - default -) +macro(SHOW_VARIABLE var type doc default) if(DEFINED ${var}) set(${var} "${${var}}" CACHE "${type}" "${doc}" FORCE) else(DEFINED ${var}) @@ -36,12 +29,12 @@ macro( endif(DEFINED ${var}) endmacro(SHOW_VARIABLE) -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~ # the following code is derived from the cmake cmakeDependentOption macro # # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~ #[=======================================================================[.rst: CMakeConditionalOption @@ -69,16 +62,17 @@ retains its old value. macro(CMAKE_CONDITIONAL_OPTION option doc condition) set(${option}_ON 1) foreach(d ${depends}) - string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") - if(${CMAKE_DEPENDENT_OPTION_DEP}) - else() - set(${option}_ON 0) - endif() + string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + if(${CMAKE_DEPENDENT_OPTION_DEP}) + + else() + set(${option}_ON 0) + endif() endforeach() if(${option}_ON) - option(${option} "${doc}" ON) + option(${option} "${doc}" ON) else() - option(${option} "${doc}" OFF) + option(${option} "${doc}" OFF) endif() endmacro() @@ -105,28 +99,37 @@ the USE_FOO option is saved so that when the option is re-enabled it retains its old value. #]=======================================================================] -macro(CMAKE_DEPENDENT_ADVANCED_OPTION option doc default depends force) - if(${option}_ISSET MATCHES "^${option}_ISSET$") - set(${option}_AVAILABLE 1) - foreach(d ${depends}) - string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") - if(${CMAKE_DEPENDENT_OPTION_DEP}) - else() - set(${option}_AVAILABLE 0) - endif() - endforeach() - if(${option}_AVAILABLE) - option(${option} "${doc}" "${default}") - set(${option} "${${option}}" CACHE BOOL "${doc}" FORCE) - mark_as_advanced(${option}) +macro( + CMAKE_DEPENDENT_ADVANCED_OPTION + option + doc + default + depends + force +) + if(${option}_ISSET MATCHES "^${option}_ISSET$") + set(${option}_AVAILABLE 1) + foreach(d ${depends}) + string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + if(${CMAKE_DEPENDENT_OPTION_DEP}) + + else() + set(${option}_AVAILABLE 0) + endif() + endforeach() + if(${option}_AVAILABLE) + option(${option} "${doc}" "${default}") + set(${option} "${${option}}" CACHE BOOL "${doc}" FORCE) + mark_as_advanced(${option}) + else() + if(${option} MATCHES "^${option}$") + + else() + set(${option} "${${option}}" CACHE INTERNAL "${doc}") + endif() + set(${option} ${force}) + endif() else() - if(${option} MATCHES "^${option}$") - else() - set(${option} "${${option}}" CACHE INTERNAL "${doc}") - endif() - set(${option} ${force}) + set(${option} "${${option}_ISSET}") endif() - else() - set(${option} "${${option}_ISSET}") - endif() endmacro() diff --git a/config/cmake/updateGitSubmodules.cmake b/config/cmake/updateGitSubmodules.cmake index a97f50fb6a..f071dea78b 100644 --- a/config/cmake/updateGitSubmodules.cmake +++ b/config/cmake/updateGitSubmodules.cmake @@ -1,5 +1,5 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Copyright (c) 2017-2020, Battelle Memorial Institute; Lawrence Livermore +# Copyright (c) 2017-2022, Battelle Memorial Institute; Lawrence Livermore # National Security, LLC; Alliance for Sustainable Energy, LLC. # See the top-level NOTICE for additional details. # All rights reserved. @@ -15,63 +15,87 @@ if(GIT_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "1.5.2")) option(${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE "Checkout and update git submodules" ON) mark_as_advanced(${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) else() - message(STATUS "${PROJECT_SOURCE_DIR} is not a Git repository. Clone ${PROJECT_NAME} with Git or ensure you get copies of all the Git submodules code.") + message( + STATUS + "${PROJECT_SOURCE_DIR} is not a Git repository. Clone ${PROJECT_NAME} with Git or ensure you get copies of all the Git submodules code." + ) endif() endif() macro(submod_update_all) - if (${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) - message(STATUS "Git Submodule Update") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_RESULT - OUTPUT_VARIABLE GIT_OUTPUT) - if(GIT_RESULT) - message(WARNING "Automatic submodule checkout with `git submodule --init` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Checkout the submodules before building.") - endif() + if(${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) + message(STATUS "Git Submodule Update") + execute_process( + COMMAND ${GIT_EXECUTABLE} submodule update --init + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE GIT_OUTPUT + ) + if(GIT_RESULT) + message( + WARNING + "Automatic submodule checkout with `git submodule --init` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Checkout the submodules before building." + ) + endif() else() - message(WARNING "SUBMODULE update has been disabled") - endif() + message(WARNING "SUBMODULE update has been disabled") + endif() endmacro() macro(submod_update target) - if (${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) - message(STATUS "Git Submodule Update ${target}") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init -- ${target} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_RESULT - OUTPUT_VARIABLE GIT_OUTPUT) - if(GIT_RESULT) - message(WARNING "Automatic submodule checkout with `git submodule --init -- $[target}` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Checkout the submodules before building.") - endif() - else() - message(WARNING "SUBMODULE update has been disabled") - endif() + if(${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) + message(STATUS "Git Submodule Update ${target}") + execute_process( + COMMAND ${GIT_EXECUTABLE} submodule update --init -- ${target} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE GIT_OUTPUT + ) + if(GIT_RESULT) + message( + WARNING + "Automatic submodule checkout with `git submodule --init -- $[target}` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Checkout the submodules before building." + ) + endif() + else() + message(WARNING "SUBMODULE update has been disabled") + endif() endmacro() function(check_submodule_status) - if (${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) - execute_process(COMMAND ${GIT_EXECUTABLE} submodule status - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_RESULT - OUTPUT_VARIABLE GIT_OUTPUT) + if(${PROJECT_NAME}_ENABLE_SUBMODULE_UPDATE) + execute_process( + COMMAND ${GIT_EXECUTABLE} submodule status + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE GIT_OUTPUT + ) - if (GIT_RESULT) - message(WARNING "Automatic submodule verification with `git submodule status` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Verify submodules before building.") - endif () + if(GIT_RESULT) + message( + WARNING + "Automatic submodule verification with `git submodule status` failed with error ${GIT_RESULT} and output ${GIT_OUTPUT}. Verify submodules before building." + ) + endif() - if (WIN32 AND NOT (MSYS OR CYGWIN)) - execute_process(COMMAND powershell "-c" "echo '${GIT_OUTPUT}' | Select-String -Pattern '^[-\\|+\\|U].*'" - OUTPUT_VARIABLE SUBMODULE_STATUS - ) - else () - execute_process(COMMAND bash "-c" "echo '${GIT_OUTPUT}' | grep '^[-\\|+\\|U].*'" - OUTPUT_VARIABLE SUBMODULE_STATUS - ) - endif () - if (NOT "${SUBMODULE_STATUS}" STREQUAL "") - message(WARNING "Submodules are not up to date. Update submodules by running `git submodule update --init` before building HELICS." - "\nOut of date submodules:\n ${SUBMODULE_STATUS}") - endif () - endif () + if(WIN32 AND NOT (MSYS OR CYGWIN)) + execute_process( + COMMAND powershell "-c" + "echo '${GIT_OUTPUT}' | Select-String -Pattern '^[-\\|+\\|U].*'" + OUTPUT_VARIABLE SUBMODULE_STATUS + ) + else() + execute_process( + COMMAND bash "-c" "echo '${GIT_OUTPUT}' | grep '^[-\\|+\\|U].*'" + OUTPUT_VARIABLE SUBMODULE_STATUS + ) + endif() + if(NOT "${SUBMODULE_STATUS}" STREQUAL "") + message( + WARNING + "Submodules are not up to date. Update submodules by running `git submodule update --init` before building HELICS." + "\nOut of date submodules:\n ${SUBMODULE_STATUS}" + ) + endif() + endif() endfunction() diff --git a/config/cmake/version_describe.cmake b/config/cmake/version_describe.cmake index 555a097454..8c025973c0 100644 --- a/config/cmake/version_describe.cmake +++ b/config/cmake/version_describe.cmake @@ -9,29 +9,25 @@ find_package(Git) -# this function is to get a nicely formatted build string for later reference in a human -# readable format that has some utility for automation. the resulting format would be -# empty if the build matches a tag exactly, and otherwise -[-dirty] if dirty is present there are uncommitted changes in the repo called -# like git_version_describe(${PROJECT_SOURCE_DIR} result) then result will contain the -# description string +# this function is to get a nicely formatted build string for later reference in a human readable +# format that has some utility for automation. the resulting format would be empty if the build +# matches a tag exactly, and otherwise -[-dirty] if dirty is present there +# are uncommitted changes in the repo called like git_version_describe(${PROJECT_SOURCE_DIR} result) +# then result will contain the description string function(git_version_describe source_path result) set(tag_desc "") # message(STATUS "Source ${source_path}") if(GIT_FOUND) execute_process( - COMMAND - ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} describe - --tags + COMMAND ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} describe --tags OUTPUT_VARIABLE TAG_DESCRIPTION ERROR_VARIABLE TAGGING_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ) if(TAGGING_ERROR) execute_process( - COMMAND ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} - describe + COMMAND ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} describe OUTPUT_VARIABLE TAG_DESCRIPTION ERROR_VARIABLE TAGGING_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE @@ -39,9 +35,8 @@ function(git_version_describe source_path result) endif() if(TAGGING_ERROR) execute_process( - COMMAND - ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} - describe --all --tags --dirty --long + COMMAND ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} describe + --all --tags --dirty --long OUTPUT_VARIABLE TAG_DESCRIPTION ERROR_VARIABLE TAGGING_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE @@ -55,9 +50,8 @@ function(git_version_describe source_path result) if(last_dash_loc GREATER 0) string(SUBSTRING ${TAG_DESCRIPTION} ${last_dash_loc} -1 hash_string) execute_process( - COMMAND - ${GIT_EXECUTABLE} -C ${source_path} --work-tree - ${source_path} describe --all --tags --dirty + COMMAND ${GIT_EXECUTABLE} -C ${source_path} --work-tree ${source_path} + describe --all --tags --dirty OUTPUT_VARIABLE TAG_DESCRIPTION2 ERROR_VARIABLE TAGGING_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE @@ -69,9 +63,7 @@ function(git_version_describe source_path result) if(hash_loc LESS 0) string(FIND ${TAG_DESCRIPTION2} "-dirty" dirty_loc) if(dirty_loc GREATER 0) - string(SUBSTRING ${TAG_DESCRIPTION2} 0 ${dirty_loc} - tag_desc - ) + string(SUBSTRING ${TAG_DESCRIPTION2} 0 ${dirty_loc} tag_desc) string(APPEND tag_desc ${hash_string} "-dirty") else() string(APPEND tag_desc ${TAG_DESCRIPTION2} ${hash_string}) @@ -87,14 +79,8 @@ function(git_version_describe source_path result) endif() endif() - set(${result} - ${tag_desc} - PARENT_SCOPE - ) + set(${result} ${tag_desc} PARENT_SCOPE) else(GIT_FOUND) - set(${result} - "" - PARENT_SCOPE - ) + set(${result} "" PARENT_SCOPE) endif(GIT_FOUND) endfunction() diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 10eb3ea814..43e5108489 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -2,15 +2,11 @@ This document contains tentative plans for changes and improvements of note in upcoming versions of the HELICS library. All dates are approximate and subject to change, but this is a snapshot of the current planning thoughts. See the [projects](https://github.com/GMLC-TDC/HELICS/projects) for additional details -## \[3.4\] ~ Late October 2022 +## \[3.4\] ~ November 2022 - Full xSDK compatibility - Full Dynamic Federation support - Single thread cores -- Iteration for entering initializing mode -- Enable data aggregation -- Wildcard support for subscribing -- Catchall interface of some type - Separate Java Interface - Observer App @@ -20,3 +16,12 @@ This document contains tentative plans for changes and improvements of note in u - Enable mesh networking in HELICS - Separate octave interface - Tag based subscriptions +- Enable data aggregation +- Wildcard support for subscriptions +- Catchall interface of some type + +## Further in the future + +- Updated MPI core +- Some sort of rollback operations +- Remote procedure call type of federate diff --git a/docs/man/manpage_out/helics_app-recorder.1 b/docs/man/manpage_out/helics_app-recorder.1 index 9f7258dc7c..e84282146d 100644 --- a/docs/man/manpage_out/helics_app-recorder.1 +++ b/docs/man/manpage_out/helics_app-recorder.1 @@ -44,7 +44,7 @@ helics_app-recorder \- records data from a federation .fi .SH "DESCRIPTION" .sp -The recorder appliation provides an easy way to capture data from a federation\&. It acts as a federate that can "capture" values or messages from publications, direct endpoints, or cloned endpoints that were created by other federates\&. +The recorder application provides an easy way to capture data from a federation\&. It acts as a federate that can "capture" values or messages from publications, direct endpoints, or cloned endpoints that were created by other federates\&. .SH "OPTIONS" .PP \-\-allow_iteration diff --git a/docs/man/recorder-contents.adoc b/docs/man/recorder-contents.adoc index b3c3968105..bad32ee41b 100644 --- a/docs/man/recorder-contents.adoc +++ b/docs/man/recorder-contents.adoc @@ -10,7 +10,7 @@ DESCRIPTION ----------- -The recorder appliation provides an easy way to capture data from a federation. +The recorder application provides an easy way to capture data from a federation. It acts as a federate that can "capture" values or messages from publications, direct endpoints, or cloned endpoints that were created by other federates. diff --git a/docs/references/configuration_options_reference.md b/docs/references/configuration_options_reference.md index 40ca1e863f..8d2b5eb6d2 100644 --- a/docs/references/configuration_options_reference.md +++ b/docs/references/configuration_options_reference.md @@ -160,6 +160,7 @@ An example of one publication, subscription, named input, endpoint, and filter i "subscriptions": [ { "only_update_on_change": false, + "default": value, } ], "inputs": [ @@ -171,6 +172,7 @@ An example of one publication, subscription, named input, endpoint, and filter i "multiple_connections_allowed": false "multi_input_handling_method": "average", "targets": ["pub1", "pub2"] + "default": 5.5, } ], "endpoints": [ @@ -256,9 +258,10 @@ A command-line-like string that specifies options for the core as it connects to - `--broker_rank=`: For MPI cores only; identifies the MPI rank of the broker - `--broker_tag=`: For MPI cores only; identifies the MPI tag of the broker - `--localport=`: Port number to use when communicating with this core -- `--autobroker`: When included the core will automatically generate a broker +- `--autobroker`: When included the core will automatically generate a broker (does not work for all core types) - `--key=`: Specifies a key to use when communicating with the broker. Only federates with this key specified will be able to talk to the broker with the same `key` value. This is used to prevent federations running on the same hardware from accidentally interfering with each other. -- `--profiler=log` - Send the profiling messages to the default logging file. `log` can be replaced with a path to an alternative file where only the profiling messages will be sent. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. +- `--profiler=log` - Send the profiling messages to the default logging file. `log` can be replaced with a path to an alternative file where only the profiling messages will be sent. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. If a file is specified it is cleared. +- `--profiler_append=somefile.txt` - Send the profiling messages to file and leave the existing contents appending new data. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. In addition to these options, all options shown in the `broker_init_string` are also valid. @@ -268,7 +271,7 @@ In addition to these options, all options shown in the `broker_init_string` are _API:_ (none) -Automatically generate a broker if one cannot be connected to. For federations with only one broker (often the case) and/or with federations containing custom federates that were developed for this particular application, it can be convenient to create the broker in the process of creating a specific federate; this option allows that to take place. The downside to this is it creates a federation with a small amount of mystery as the broker is not clearly shown to be launched as its own federate alongside the other federates and those unfamiliar with the federation composition may have to spend some extra time to understand where the broker is coming from. +Automatically generate a broker if one cannot be connected to. For federations with only one broker (often the case) and/or with federations containing custom federates that were developed for this particular application, it can be convenient to create the broker in the process of creating a specific federate; this option allows that to take place. The downside to this is it creates a federation with a small amount of mystery as the broker is not clearly shown to be launched as its own federate alongside the other federates and those unfamiliar with the federation composition may have to spend some extra time to understand where the broker is coming from. This option does not work for all core types, it is specifically designed for inproc and testing cores. Others may be added later. --- @@ -310,8 +313,8 @@ String used to define the configuration of the broker if one is autogenerated. S - `--children=` - The minimum number of child objects the broker should expect before allowing entry to the initializing state. - `--subbrokers=` - The minimum number of child objects the broker should expect before allowing entry to the initializing state. Same as `--children` but might be clearer in some cases with multilevel hierarchies. - `--brokerkey=` - A broker key to use for connections to ensure federates are connecting with a specific broker and only appropriate federates connect with the broker. See [simultaneous co-simulations](../user-guide/advanced_topics/simultaneous_cosimulations.md) for more information. -- `--profiler=log` - Send the profiling messages to the default logging file. `log` can be replaced with a path to an alternative file where only the profiling messages will be sent. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. -- `--profiler=log` - Send the profiling messages to the default logging file. `log` can be replaced with a path to an alternative file where only the profiling messages will be sent. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. +- `--profiler=log` - Send the profiling messages to the default logging file. `log` can be replaced with a path to an alternative file where only the profiling messages will be sent. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. If a file is specified it is cleared. +- `--profiler_append=somefile.txt` - Send the profiling messages to file and leave the existing contents appending new data. See the [User Guide page on profiling](../user-guide/advanced_topics/profiling.md) for further details. - `--timemonitor=` - Specify the name of the federate to monitor the time from and generate periodic log messages in the broker as the federate updates its time. - `--timemonitorperiod=` - can only be used with `--timemonitor`, set the minimum time period which must elapse in simulation before another log message from the time monitor is generated - `--logbuffer` - Enable buffering recent log messages for retrieval with the "logs" query. Optionally specify the size of the circular log buffer; defaults to 10 messages if no size is supplied. @@ -382,8 +385,10 @@ _Property's enumerated name:_ `HELICS_PROPERTY_INT_LOG_LEVEL` [271] _Valid values:_ +- `none` - `HELICS_LOG_LEVEL_NO_PRINT` - `no_print` - `HELICS_LOG_LEVEL_NO_PRINT` - `error` - `HELICS_LOG_LEVEL_ERROR` +- `profiling` - `HELICS_LOG_LEVEL_PROFILING` - `warning` - `HELICS_LOG_LEVEL_WARNING` - `summary` - `HELICS_LOG_LEVEL_SUMMARY` - `connections` - `HELICS_LOG_LEVEL_CONNECTIONS` @@ -758,6 +763,34 @@ This option allows the specific numerical definition of "change" when using the --- +### `default` + +_API:_ `helicsInputSetDefaultX` +[C++ input](https://docs.helics.org/en/latest/doxygen/classhelics_1_1Input.html#a55056ac9dd2895270f575827dd9951c7) +| [C input](api-reference/C_API.md#input) +| [Python input](https://python.helics.org/api/capi-py.html#helicsInputSetDefault) +| [Julia input](https://julia.helics.org/latest/api/#HELICS.helicsInputSetDefulat-Tuple{HELICS.Input,XXX}) + +This option allows specifying the default value used when no publication has been received. Each datatype has its own API call such as: + +- `helicsInputSetDefaultBoolean()` +- `helicsInputSetDefaultBytes()` +- `helicsInputSetDefaultChar()` +- `helicsInputSetDefaultComplex()` +- `helicsInputSetDefaultComplexVector()` +- `helicsInputSetDefaulDouble()` +- `helicsInputSetDefaultInteger()` +- `helicsInputSetDefaultRaw()` +- `helicsInputSetDefaultString()` (used for JSONs) +- `helicsInputSetDefaultVector()` + +Though they are not as obviously named, the following two APIs do provide a means of setting the default value as well: + +- `helicsInputSetDefaultTime()` - set the default using a HelicsTime value +- `helicsInputSetDefaultNamedPoint()` -set the default NamedPoint which is a pair of a string and double used for tagged values or set points + +--- + ### `connection_required` | `connectionrequired` | `connectionRequired` [false] _API:_ `helicsFederateInfoSetFlagOption` diff --git a/docs/user-guide/advanced_topics/profiling.md b/docs/user-guide/advanced_topics/profiling.md index e9c0055975..da02495aec 100644 --- a/docs/user-guide/advanced_topics/profiling.md +++ b/docs/user-guide/advanced_topics/profiling.md @@ -37,7 +37,8 @@ Profiling can be enabled at any level of the hierarchy in HELICS and when enable Profiling is enabled via the command prompt by passing the `--profiler` option when calling `helics_broker`. -- `--profiler=save_profile2.txt` will save profiling data to a text file `save_profile2.txt` +- `--profiler=save_profile2.txt` will clear save_profile2.txt and save new profiling data to a text file `save_profile2.txt` +- `--profiler_append=save_profile2.txt` will append profiling data to the text file `save_profile2.txt` - `--profiler=log` will capture the profile text output to the normal log file or callback - `--profiler` is the same as `--profiler=log` @@ -47,7 +48,8 @@ Enabling this flag will pass in the appropriate flags to all children brokers an Profiling is enabled via the `coreinitstring` by adding a `--profiler` option. -- `--profiler=save_profile2.txt` will save profiling data to a text file `save_profile2.txt` +- `--profiler=save_profile2.txt` will clear save_profile2.txt and save new profiling data to a text file `save_profile2.txt` +- `--profiler_append=save_profile2.txt` will append profiling data to the text file `save_profile2.txt` - `--profiler=log` will capture the profile text output to the normal log file or callback - `--profiler` is the same as `--profiler=log` @@ -82,4 +84,4 @@ Some can be set through the flags option for federate configuration. This capability is preliminary and subject to change based on initial feedback. In HELICS 3 there will probably be some additional command infrastructure to handle profiling as well added in the future. -If timing is done in the federate itself as well there will be a time gap; there is some processing code between the profiling message, and when the actual function call returns, but it is not blocking and should be fairly short, though dependent on how much data is actually transferred in the federate. +If timing is done in the federate itself as well there will be a time gap; there is some processing code between the profiling message, and when the actual function call returns, but it is not blocking and should be fairly short, though dependent on how much data is actually transferred in the federate. Profiling does not work with callback federates. diff --git a/docs/user-guide/fundamental_topics/interface_configuration.md b/docs/user-guide/fundamental_topics/interface_configuration.md index bd79431bfe..93a87f6903 100644 --- a/docs/user-guide/fundamental_topics/interface_configuration.md +++ b/docs/user-guide/fundamental_topics/interface_configuration.md @@ -66,9 +66,25 @@ Below is a sample JSON configuration file with some of the more common options. "unit":"A", "global": true, "only_update_on_change": true, - "tolerance": 0.2 + "tolerance": 0.2, + "default":0.91 } - ] + ], + "inputs": [ + { + "key": "ipt2", + "type": "double", + "connection_required": true, + "target": "pub1", + "global": true, + "default":"3.67", + "tags": [ + { "name": "period", "value": "0.7" }, + { "name": "description", "value": "a test input" } + ] + } + //specify an input with a target multiple targets could be specified like "targets":["pub1","pub2","pub3"] + ], } ``` @@ -93,15 +109,29 @@ Below is a sample JSON configuration file with some of the more common options. - `type` - Data type, such as integer, double, complex. - `units` - The units can be any sort of unit string, a wide assortment is supported and can be compound units such as m/s^2 and the conversion will convert as long as things are convertible. The unit match is also checked for other types and an error if mismatching units are detected. A warning is also generated if the units are not understood and not matching. The unit checking and conversion is only active if both the publication and subscription specify units. HELICS is able to do some levels of unit conversion, currently only on double type publications but more may be added in the future. - `only_transmit_on_change` and `tolerance` - Publications will only send a new value out to the federation when the value has changed more than the delta specified by `tolerance`. + - `alias` - an alternate name for the publication must be globally unique for publications - `tags` - Arbitrary string value pairs that can be applied to interfaces. Tags are available to others through queries but are not transmitted by default. They can be used to store additional information about an interface that might be useful to applications. At some point in the future automated connection routines will make use of them. "tags" are applicable to any interface and can also be used on federates. - **`subscriptions`** - These are lists of the values being sent to and from the given federate. + - `key` - This string identifies the federation-unique value that this federate wishes to receive. If `global` has been set to `false` in the `publications` JSON configuration file, the name of the value is formatted as `/`. Both of these strings can be found in the publishing federate's JSON configuration file as the `name` and `key` strings, respectively. If `global` is `true` the string is the publishing federate's `key` value. - `required` - The message being subscribed to must be provided by some other publisher in the federation. - `type` - Data type, such as integer, double, complex. - `units` - Same as with `publications`. - `global` - Applies to the `key`, same as with `publications`. + - `default` - set the default value to return if no publications have been received - `only_update_on_change` and `tolerance` - Subscriptions will only consider a new value received when that value has changed more than the delta specified by `tolerance`. +- **`inputs`** - These are lists of the values being sent to and from the given federate. + - `name` - the name of the input. + - `required` - The input must have a valid target + - `type` - Data type, such as integer, double, complex. + - `units` - Same as with `publications`. + - `global` - Applies to the `key`, same as with `publications`. + - `default` - set the default value to return if no publications have been received + - `target` - A key for a publication the input should receive, may be an array such as ["pub1","pub2","pub3"] + - `tags` - name and value pairs defining user tags for the interface + - `only_update_on_change` and `tolerance` - Inputs will only consider a new value received when that value has changed more than the delta specified by `tolerance`. + ## API Configuration Configuring the federate interface with the API is done internal to a user-written simulator. The specific API used will depend on the language the simulator is written in. Native APIs for HELICS are available in [C++](../../doxygen/index.md) and [C](../../references/api-reference/C_API.md). MATLAB, Java, Julia, Nim, and Python all support the C API calls (ex: `helicsFederateEnterExecutionMode()`). Python and Julia also have native APIs (see: [Python (PyHELICS)](https://python.helics.org/api/), [Julia](https://gmlc-tdc.github.io/HELICS.jl/latest/api/)) that wrap the C APIs to better support the conventions of their languages. The [API References](../../references/api-reference/index.md) page contains links to the APIs. diff --git a/docs/user-guide/installation/helics_cmake_options.md b/docs/user-guide/installation/helics_cmake_options.md index 676bc6dbf0..ad7e3cd6d9 100644 --- a/docs/user-guide/installation/helics_cmake_options.md +++ b/docs/user-guide/installation/helics_cmake_options.md @@ -98,3 +98,4 @@ There are a few options in the CMake system that are not visible in the GUI they - `HELICS_DISABLE_GIT_OPERATIONS` : will turn off any of the helper tools that require git, this is useful in a couple cases for building packages and other situations where updates shouldn't be checked and no modifications should be made. - `HELICS_SKIP_ZMQ_INSTALL`: This is only relevant if ZMQ is built as part of the compilation process, but it skips the installation of zmq as part of HELICS install in that case. - `HELICS_BENCHMARK_SHIFT_FACTOR`: For running the benchmarks this shift factor can be used to scale the number of federates used for the benchmark tests. If used it is required to be a number and is power of 2 shift from nominal values. For example for a small system a shift factor of -1 or -2 might be appropriate for the benchmarks not to take too long. The default for systems with 4 or fewer cores is `-1` and 0 for larger compute systems. For small 2 core systems a value of -2 might be appropriate. For some very large systems a bigger value might be able to be used. +- `HELICS_HIDE_CMAKE_VARIABLES`: When using HELICS as a subproject in a CMake build this option can be enabled to hide all HELICS related variables in CMake so they won't show up in the CMake GUI. diff --git a/interfaces/java/addLoadLibraryCommand.cmake b/interfaces/java/addLoadLibraryCommand.cmake index 8f87aeddae..c11aafae87 100644 --- a/interfaces/java/addLoadLibraryCommand.cmake +++ b/interfaces/java/addLoadLibraryCommand.cmake @@ -7,21 +7,24 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# addLoadLibraryCommand.cmake -#adds a load library function to the helics.java +# addLoadLibraryCommand.cmake adds a load library function to the helics.java -if (NOT LIBRARY_FILE) -set(LIBRARY_FILE helics) +if(NOT LIBRARY_FILE) + set(LIBRARY_FILE helics) else() -get_filename_component(LIBRARY_FILE ${LIBRARY_FILE} NAME_WE) -STRING(REGEX REPLACE "^lib" "" LIBRARY_FILE ${LIBRARY_FILE}) + get_filename_component(LIBRARY_FILE ${LIBRARY_FILE} NAME_WE) + string(REGEX REPLACE "^lib" "" LIBRARY_FILE ${LIBRARY_FILE}) endif() file(READ helicsJNI.java HELICS_JNI_SOURCE) string(FIND "${HELICS_JNI_SOURCE}" "System.loadLibrary" ALREADY_LOADED) -if (${ALREADY_LOADED} LESS 0) -string(REPLACE "public class helicsJNI {" - "public class helicsJNI {\n static {\n System.loadLibrary\(\"${LIBRARY_FILE}\"\);\n }" HELICS_JNI_SOURCE - "${HELICS_JNI_SOURCE}") +if(${ALREADY_LOADED} LESS 0) + string( + REPLACE + "public class helicsJNI {" + "public class helicsJNI {\n static {\n System.loadLibrary\(\"${LIBRARY_FILE}\"\);\n }" + HELICS_JNI_SOURCE + "${HELICS_JNI_SOURCE}" + ) -file(WRITE helicsJNI.java "${HELICS_JNI_SOURCE}") + file(WRITE helicsJNI.java "${HELICS_JNI_SOURCE}") endif() diff --git a/interfaces/java/installJar.cmake b/interfaces/java/installJar.cmake deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/interfaces/java/javaSwigGenerateOnly.cmake b/interfaces/java/javaSwigGenerateOnly.cmake index 2f08df93f6..d32b26c46c 100644 --- a/interfaces/java/javaSwigGenerateOnly.cmake +++ b/interfaces/java/javaSwigGenerateOnly.cmake @@ -7,44 +7,37 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#File used to generate the Java interface and overwrite the existing files if requested +# File used to generate the Java interface and overwrite the existing files if requested if(SWIG_VERSION VERSION_GREATER "4.0.0") - set(SWIG_DOXYGEN_FLAG "-doxygen") + set(SWIG_DOXYGEN_FLAG "-doxygen") endif() - get_filename_component(helics.i_INCLUDE_DIR "${HELICS_SWIG_helics.i_FILE}" DIRECTORY) +get_filename_component(helics.i_INCLUDE_DIR "${HELICS_SWIG_helics.i_FILE}" DIRECTORY) - # custom command for building the wrap file - add_custom_command( +# custom command for building the wrap file +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/helicsJava.c COMMAND - "${SWIG_EXECUTABLE}" "-java" "-package" "com.java.helics" -o "helicsJava.c" "${SWIG_DOXYGEN_FLAG}" - "-I${HELICS_SOURCE_DIR}/src/helics/shared_api_library/backup/" - "-I${helics.i_INCLUDE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/helicsJava.i - DEPENDS - ${HELICS_SWIG_helics.i_FILE} - ${CMAKE_CURRENT_SOURCE_DIR}/helicsJava.i - ${HELICS_SOURCE_DIR}/src/helics/shared_api_library/backup/helics/helics.h - ${CMAKE_CURRENT_SOURCE_DIR}/java_maps.i - ) + "${SWIG_EXECUTABLE}" "-java" "-package" "com.java.helics" -o "helicsJava.c" + "${SWIG_DOXYGEN_FLAG}" "-I${HELICS_SOURCE_DIR}/src/helics/shared_api_library/backup/" + "-I${helics.i_INCLUDE_DIR}" ${CMAKE_CURRENT_SOURCE_DIR}/helicsJava.i + DEPENDS ${HELICS_SWIG_helics.i_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/helicsJava.i + ${HELICS_SOURCE_DIR}/src/helics/shared_api_library/backup/helics/helics.h + ${CMAKE_CURRENT_SOURCE_DIR}/java_maps.i +) - if(HELICS_OVERWRITE_INTERFACE_FILES) +if(HELICS_OVERWRITE_INTERFACE_FILES) add_custom_target( - javafile_overwrite ALL - COMMAND - ${CMAKE_COMMAND} -D TARGET_DIR=${CMAKE_CURRENT_SOURCE_DIR}/interface -P - ${CMAKE_CURRENT_SOURCE_DIR}/overwriteJavaFiles.cmake - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/helicsJava.c + javafile_overwrite ALL + COMMAND ${CMAKE_COMMAND} -D TARGET_DIR=${CMAKE_CURRENT_SOURCE_DIR}/interface -P + ${CMAKE_CURRENT_SOURCE_DIR}/overwriteJavaFiles.cmake + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/helicsJava.c ) set_target_properties(javafile_overwrite PROPERTIES FOLDER interfaces) - else(HELICS_OVERWRITE_INTERFACE_FILES) - #extra target for generation only and no overwrite so the dependency actually gets evaluated by cmake - add_custom_target( - java_create ALL - COMMAND - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/helicsJava.c - ) +else(HELICS_OVERWRITE_INTERFACE_FILES) + # extra target for generation only and no overwrite so the dependency actually gets evaluated by + # cmake + add_custom_target(java_create ALL COMMAND DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/helicsJava.c) set_target_properties(java_create PROPERTIES FOLDER interfaces) endif(HELICS_OVERWRITE_INTERFACE_FILES) diff --git a/interfaces/java/overwriteJavaFiles.cmake b/interfaces/java/overwriteJavaFiles.cmake index b9ee6eb0eb..f3bfcd64c9 100644 --- a/interfaces/java/overwriteJavaFiles.cmake +++ b/interfaces/java/overwriteJavaFiles.cmake @@ -9,8 +9,8 @@ configure_file(helicsJava.c ${TARGET_DIR}/helicsJava.c COPYONLY) - FILE(GLOB JAVA_FILES *.java) +file(GLOB JAVA_FILES *.java) - FILE(COPY ${JAVA_FILES} DESTINATION ${TARGET_DIR}) +file(COPY ${JAVA_FILES} DESTINATION ${TARGET_DIR}) - message(STATUS "overwriting java files in source directory") +message(STATUS "overwriting java files in source directory") diff --git a/interfaces/octave/generateOCTcreationScript.cmake b/interfaces/octave/generateOCTcreationScript.cmake index 46a2417bfb..8faf65987a 100644 --- a/interfaces/octave/generateOCTcreationScript.cmake +++ b/interfaces/octave/generateOCTcreationScript.cmake @@ -10,9 +10,9 @@ get_filename_component(LIBRARY_BUILD_LOCATION ${LIBRARY_FILE} DIRECTORY) get_filename_component(LIBRARY_NAME ${LIBRARY_FILE} NAME_WE) -IF (UNIX) +if(UNIX) string(REGEX REPLACE "^lib" "" LIBRARY_NAME ${LIBRARY_NAME}) -ENDIF(UNIX) +endif(UNIX) get_filename_component(BUILD_DIR ${BUILD_FILE} DIRECTORY) configure_file(${SOURCE_DIR}/mkhelicsOCTFile.m.in ${BUILD_DIR}/mkhelicsOCTFile.m) diff --git a/interfaces/octave/modifyOctSourceFile.cmake b/interfaces/octave/modifyOctSourceFile.cmake index 0cd876e306..2fce891a9f 100644 --- a/interfaces/octave/modifyOctSourceFile.cmake +++ b/interfaces/octave/modifyOctSourceFile.cmake @@ -9,20 +9,20 @@ # modifyOctSourceFile.cmake -if (WIN32) +if(WIN32) if(helicsOCTAVE_wrap.cxx IS_NEWER_THAN helicsOCTAVE_wrap.cpp) if(VOID_SIZE EQUAL 8) file(READ helicsOCTAVE_wrap.cxx HELICS_OCT_SOURCE) -string(REPLACE "long swig_this\(\) const" - "long long swig_this\(\)" HELICS_OCT_SOURCE - "${HELICS_OCT_SOURCE}") -string(REPLACE "return \(long\) this" - "return \(long long\) this" HELICS_OCT_SOURCE - "${HELICS_OCT_SOURCE}") -string(REPLACE "\(long\) types[0].second.ptr" - "\(long long\) types[0].second.ptr" HELICS_OCT_SOURCE - "${HELICS_OCT_SOURCE}") + string(REPLACE "long swig_this\(\) const" "long long swig_this\(\)" HELICS_OCT_SOURCE + "${HELICS_OCT_SOURCE}" + ) + string(REPLACE "return \(long\) this" "return \(long long\) this" HELICS_OCT_SOURCE + "${HELICS_OCT_SOURCE}" + ) + string(REPLACE "\(long\) types[0].second.ptr" "\(long long\) types[0].second.ptr" + HELICS_OCT_SOURCE "${HELICS_OCT_SOURCE}" + ) file(WRITE helicsOCTAVE_wrap.cpp "${HELICS_OCT_SOURCE}") set(FILE_WRITTEN TRUE) @@ -30,6 +30,6 @@ string(REPLACE "\(long\) types[0].second.ptr" endif() endif(WIN32) -if (NOT FILE_WRITTEN) +if(NOT FILE_WRITTEN) configure_file(helicsOCTAVE_wrap.cxx helicsOCTAVE_wrap.cpp COPYONLY) endif() diff --git a/scripts/run-ci-tests.sh b/scripts/run-ci-tests.sh index a95e5f01ff..11ffc23aba 100755 --- a/scripts/run-ci-tests.sh +++ b/scripts/run-ci-tests.sh @@ -95,11 +95,11 @@ else ;; *continuous*) TEST_CONFIG="Continuous" - CTEST_OPTIONS+=" --timeout 600" + CTEST_OPTIONS+=" --timeout 1000" ;; *ci*) TEST_CONFIG="Continuous" - CTEST_OPTIONS+=" --timeout 600" + CTEST_OPTIONS+=" --timeout 1000" ;; *) # Use whatever user gave for TEST_CONFIG diff --git a/scripts/run-coverage-tests.sh b/scripts/run-coverage-tests.sh index 367bd8cc0b..9b44e946a4 100755 --- a/scripts/run-coverage-tests.sh +++ b/scripts/run-coverage-tests.sh @@ -1,14 +1,14 @@ #!/bin/bash tests=( - ./bin/core-tests - ./bin/common-tests + "./bin/core-tests --gtest_filter=-*nocov*" + "./bin/common-tests --gtest_filter=-*nocov*" "./bin/system-tests --gtest_filter=-*nocov*" "./bin/helics_apps-tests --gtest_filter=-*nocov*" "./bin/shared-library-tests-cpp --gtest_filter=-*death*:*nocov*" "./bin/shared-library-tests --gtest_filter=-*death*:*nocov*" "./bin/application-api-tests --gtest_filter=-*nocov*" "./bin/helics_webserver-tests --gtest_filter=-*nocov*" - "./bin/network-tests --gtest_filter=*" + "./bin/network-tests --gtest_filter=-*nocov*" ) SUMRESULT=0 diff --git a/src/helics/CMakeLists.txt b/src/helics/CMakeLists.txt index ac00d0c827..b35c3ea696 100644 --- a/src/helics/CMakeLists.txt +++ b/src/helics/CMakeLists.txt @@ -55,7 +55,9 @@ file(COPY ${CMAKE_CURRENT_BINARY_DIR}/helics_cxx_export.h ) if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - set_target_properties(helics_application_api helics_common helics_core PROPERTIES FOLDER helics) + set_target_properties( + helics_application_api helics_common helics_core helics_network PROPERTIES FOLDER helics + ) endif() if(HELICS_BUILD_APP_LIBRARY) @@ -68,4 +70,8 @@ endif(HELICS_BUILD_APP_LIBRARY) if(NOT HELICS_DISABLE_C_SHARED_LIB) add_subdirectory(shared_api_library) add_subdirectory(cpp98) + + if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set_target_properties(helics helicsCpp98_ide PROPERTIES FOLDER helics) + endif() endif() diff --git a/src/helics/application_api/AsyncFedCallInfo.hpp b/src/helics/application_api/AsyncFedCallInfo.hpp index bb5adcde3a..b379345996 100644 --- a/src/helics/application_api/AsyncFedCallInfo.hpp +++ b/src/helics/application_api/AsyncFedCallInfo.hpp @@ -15,15 +15,23 @@ namespace helics { /** helper class for Federate info that holds the futures for asynchronous calls*/ class AsyncFedCallInfo { public: - std::future initFuture; /**future for the Enter initialization call*/ - std::future execFuture; /** future for the enter execution mode call*/ - std::future