From 2d7f8b0fb2351a7dad8b8a93938302b7e2ba65f8 Mon Sep 17 00:00:00 2001 From: Lars Ivar Hatledal Date: Fri, 30 Jun 2023 10:31:44 +0200 Subject: [PATCH] update --- CMakeLists.txt | 16 +++++++++++----- cmake/config.cmake.in | 4 ++++ src/CMakeLists.txt | 22 +++++----------------- src/proxyfmu/CMakeLists.txt | 6 +++--- tool/CMakeLists.txt | 2 +- tool/cli/CMakeLists.txt | 5 ----- tool/proxyfmu/CMakeLists.txt | 11 +++++++---- tool/proxyfmu/proxyfmu.cpp | 22 +++++++++++++++++++++- tool/proxyfmu/rng.hpp | 26 -------------------------- 9 files changed, 52 insertions(+), 62 deletions(-) delete mode 100644 tool/proxyfmu/rng.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ad0bef4..740baf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.17) -set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file") +set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" projectVersion) project("libecos" VERSION ${projectVersion}) message("Current ${PROJECT_NAME} version: ${CMAKE_PROJECT_VERSION}\n") @@ -39,9 +39,9 @@ endif () # Dependencies # ============================================================================== -set(SUBPROCESS_INCLUDE_DIR ${CMAKE_BINARY_DIR}/thirdparty) +set(SUBPROCESS_INCLUDE_DIR "${CMAKE_BINARY_DIR}/thirdparty") file(DOWNLOAD https://raw.githubusercontent.com/Ecos-platform/subprocess.h/master/subprocess.h - ${SUBPROCESS_INCLUDE_DIR}/subprocess/subprocess.h) + "${SUBPROCESS_INCLUDE_DIR}/subprocess/subprocess.h") find_package(fmt CONFIG REQUIRED) find_package(spdlog CONFIG REQUIRED) @@ -81,6 +81,10 @@ if (ECOS_BUILD_EXAMPLES OR ECOS_BUILD_TESTS) endif () +# ============================================================================== +# Exports and remaining installation +# ============================================================================== + configure_package_config_file(cmake/config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/ecos-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/ecos @@ -96,9 +100,11 @@ install( DESTINATION ${CMAKE_INSTALL_DATADIR}/ecos) -install(TARGETS ecos EXPORT ecos-targets) +install( + TARGETS libecos ecos proxyfmu + EXPORT ecos-targets +) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT ecos-targets NAMESPACE ecos:: DESTINATION ${CMAKE_INSTALL_DATADIR}/ecos) - diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index 6d27bb7..fe94611 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -8,4 +8,8 @@ find_dependency(spdlog CONFIG REQUIRED) find_dependency(libzip CONFIG REQUIRED) find_dependency(pugixml CONFIG REQUIRED) find_dependency(Thrift CONFIG REQUIRED) +find_dependency(CLI11 CONFIG REQUIRED) +find_dependency(unofficial-fmilib CONFIG REQUIRED +include("${CMAKE_CURRENT_LIST_DIR}/ecos-targets.cmake") +check_required_components(ecos) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4bb7e7a..d6a3eb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ -set(publicHeaderDir ${PROJECT_SOURCE_DIR}/include) add_subdirectory(proxyfmu) @@ -33,7 +32,7 @@ set(publicHeaders set(publicHeadersFull) foreach (header IN LISTS commonPublicHeaders) - list(APPEND commonPublicHeadersFull "${publicHeaderDir}/${header}") + list(APPEND commonPublicHeadersFull "${PROJECT_SOURCE_DIR}/include/${header}") endforeach () set(privateHeaders @@ -125,10 +124,10 @@ target_link_libraries(libecos PUBLIC fmt::fmt PRIVATE - thrift::thrift - pugixml::pugixml libzip::zip spdlog::spdlog + thrift::thrift + pugixml::pugixml unofficial::fmilib::fmilib ) if (UNIX) @@ -143,16 +142,5 @@ if (ECOS_BUILD_CLIB) libecos) endif () - -# ============================================================================== -# Installation rules -# ============================================================================== - -install( - TARGETS libecos - EXPORT ecos-targets -) -install( - DIRECTORY "${publicHeaderDir}/ecos" - DESTINATION "${CMAKE_INSTALL_DATADIR}/ecos" -) +# Make sure executable is up to date +#add_dependencies(libecos proxyfmu) diff --git a/src/proxyfmu/CMakeLists.txt b/src/proxyfmu/CMakeLists.txt index a9cd44b..e52ed99 100644 --- a/src/proxyfmu/CMakeLists.txt +++ b/src/proxyfmu/CMakeLists.txt @@ -57,15 +57,15 @@ install( "${CMAKE_CURRENT_SOURCE_DIR}/boot.thrift" "${CMAKE_CURRENT_SOURCE_DIR}/defs.thrift" "${CMAKE_CURRENT_SOURCE_DIR}/service.thrift" - DESTINATION "thrift/definitions" + DESTINATION "${CMAKE_INSTALL_DATADIR}/thrift/definitions" ) install( DIRECTORY "${CMAKE_BINARY_DIR}/generated/java" - DESTINATION "thrift" + DESTINATION "${CMAKE_INSTALL_DATADIR}/thrift" ) install( DIRECTORY "${CMAKE_BINARY_DIR}/generated/proxyfmu/thrift/" - DESTINATION "thrift/cpp" + DESTINATION "${CMAKE_INSTALL_DATADIR}/thrift/cpp" ) diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index ea51b15..6eb3492 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(proxyfmu) -add_subdirectory(cli) \ No newline at end of file +add_subdirectory(cli) diff --git a/tool/cli/CMakeLists.txt b/tool/cli/CMakeLists.txt index 4a2ac85..2b22f0b 100644 --- a/tool/cli/CMakeLists.txt +++ b/tool/cli/CMakeLists.txt @@ -5,8 +5,3 @@ target_link_libraries(ecos libecos CLI11::CLI11 ) - -install( - TARGETS ecos - DESTINATION ecos-targets} -) diff --git a/tool/proxyfmu/CMakeLists.txt b/tool/proxyfmu/CMakeLists.txt index cf192c5..f219168 100644 --- a/tool/proxyfmu/CMakeLists.txt +++ b/tool/proxyfmu/CMakeLists.txt @@ -1,10 +1,13 @@ -add_executable(proxyfmu - proxyfmu.cpp +set(sources + "proxyfmu.cpp" "handlers/fmu_service_handler.cpp" "handlers/boot_service_handler.cpp" - "$" - "${generatedSourcesDir}/ecos/lib_info.cpp") + + "${generatedSourcesDir}/ecos/lib_info.cpp" + ) + +add_executable(proxyfmu ${sources} "$") target_include_directories(proxyfmu PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/tool/proxyfmu/proxyfmu.cpp b/tool/proxyfmu/proxyfmu.cpp index 737d94d..f16afb2 100644 --- a/tool/proxyfmu/proxyfmu.cpp +++ b/tool/proxyfmu/proxyfmu.cpp @@ -1,13 +1,13 @@ #include "handlers/boot_service_handler.hpp" #include "handlers/fmu_service_handler.hpp" -#include "rng.hpp" #include "ecos/lib_info.hpp" #include #include #include +#include #include #include #include @@ -34,6 +34,26 @@ const int COMMANDLINE_ERROR = 1; const int UNHANDLED_ERROR = 2; +class rng +{ + +public: + rng(int min, int max) + : mt_(std::random_device()()) + , dist_(min, max) + { } + + int next() + { + return dist_(mt_); + } + +private: + std::mt19937 mt_; + std::uniform_int_distribution dist_; + +}; + class ServerReadyEventHandler : public TServerEventHandler { diff --git a/tool/proxyfmu/rng.hpp b/tool/proxyfmu/rng.hpp deleted file mode 100644 index d2a1e51..0000000 --- a/tool/proxyfmu/rng.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -#ifndef ECOS_FIXED_RANGE_RANDOM_GENERATOR_HPP -#define ECOS_FIXED_RANGE_RANDOM_GENERATOR_HPP - -#include - -class rng -{ - -private: - std::mt19937 mt_; - std::uniform_int_distribution dist_; - -public: - rng(int min, int max) - : mt_(std::random_device()()) - , dist_(min, max) - { } - - int next() - { - return dist_(mt_); - } -}; - -#endif // ECOS_FIXED_RANGE_RANDOM_GENERATOR_HPP