Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Jun 30, 2023
1 parent 2d72742 commit 2d7f8b0
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 62 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)

4 changes: 4 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
22 changes: 5 additions & 17 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
set(publicHeaderDir ${PROJECT_SOURCE_DIR}/include)

add_subdirectory(proxyfmu)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
6 changes: 3 additions & 3 deletions src/proxyfmu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 1 addition & 1 deletion tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

add_subdirectory(proxyfmu)
add_subdirectory(cli)
add_subdirectory(cli)
5 changes: 0 additions & 5 deletions tool/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ target_link_libraries(ecos
libecos
CLI11::CLI11
)

install(
TARGETS ecos
DESTINATION ecos-targets}
)
11 changes: 7 additions & 4 deletions tool/proxyfmu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

add_executable(proxyfmu
proxyfmu.cpp
set(sources
"proxyfmu.cpp"
"handlers/fmu_service_handler.cpp"
"handlers/boot_service_handler.cpp"
"$<TARGET_OBJECTS:proxyfmu-service>"
"${generatedSourcesDir}/ecos/lib_info.cpp")

"${generatedSourcesDir}/ecos/lib_info.cpp"
)

add_executable(proxyfmu ${sources} "$<TARGET_OBJECTS:proxyfmu-service>")
target_include_directories(proxyfmu
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down
22 changes: 21 additions & 1 deletion tool/proxyfmu/proxyfmu.cpp
Original file line number Diff line number Diff line change
@@ -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 <CLI/CLI.hpp>
#include <functional>
#include <iostream>
#include <random>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TTransportUtils.h>
Expand All @@ -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<int> dist_;

};

class ServerReadyEventHandler : public TServerEventHandler
{

Expand Down
26 changes: 0 additions & 26 deletions tool/proxyfmu/rng.hpp

This file was deleted.

0 comments on commit 2d7f8b0

Please sign in to comment.