Commit 51d59810 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

cmake: libirritator is now a header only library

parent 4597fa04
Pipeline #16406 passed with stage
in 1 minute and 37 seconds
......@@ -4,24 +4,17 @@ project(libirritator VERSION 0.1.0 LANGUAGES CXX)
option(WITH_DEBUG "enable maximium debug code. [default: ON]" ON)
set(public_irritator_header
include/irritator/core.hpp)
set(private_irritator_source
src/adder.cpp
src/counter.cpp
src/generator.cpp)
add_library(libirritator ${public_irritator_header} ${private_irritator_source})
option(BUILD_SHARED_LIBS "Build shared library" OFF)
include(GenerateExportHeader)
generate_export_header(libirritator
EXPORT_MACRO_NAME BX_EXPORT
NO_EXPORT_MACRO_NAME BX_NO_EXPORT
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/irritator/export)
target_compile_options(libirritator
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/irritator/core.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/irritator/io.hpp)
add_library(libirritator INTERFACE)
target_sources(libirritator INTERFACE
"$<BUILD_INTERFACE:${public_irritator_header}>")
target_include_directories(libirritator INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(libirritator SYSTEM INTERFACE
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_compile_options(libirritator INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-pipe -march=native
$<$<CONFIG:Debug>:-O0 -ggdb3 -Wall -Wextra>>
......@@ -29,30 +22,16 @@ target_compile_options(libirritator
/EHsc /bigobj /Zc:__cplusplus /std:c++latest
$<$<CONFIG:Debug>:/Od /W3 /Zi>>)
target_include_directories(libirritator PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>)
target_link_libraries(libirritator
PRIVATE
threads)
set_target_properties(libirritator PROPERTIES
OUTPUT_NAME "irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
CXX_STANDARD 20)
target_compile_definitions(libirritator
PRIVATE
$<$<BOOL:${WITH_DEBUG}>:IRRITATOR_ENABLE_DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
VERSION_MINOR=${PROJECT_VERSION_MINOR}
VERSION_PATCH=${PROJECT_VERSION_PATCH})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/IrritatorConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/IrritatorConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/IrritatorConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(TARGETS libirritator
EXPORT libirritator-targets
......@@ -61,7 +40,11 @@ install(TARGETS libirritator
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(IRRITATOR_DEPENDENCIES "")
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/IrritatorConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/IrritatorConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
configure_file(irritator.pc.in
"${CMAKE_BINARY_DIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.pc"
@ONLY)
......@@ -74,18 +57,6 @@ install(DIRECTORY include/irritator
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/irritator/export
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}/irritator)
install(EXPORT libirritator-targets
FILE libirritator-targets.cmake
NAMESPACE libirritator::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/irritator-${VLE_ABI})
# This makes the project importable from the build directory
export(TARGETS libirritator FILE LibirritatorConfig.cmake)
function(irritator_add_test test_name)
add_executable(${test_name} ${ARGN})
......@@ -154,16 +125,14 @@ function(irritator_add_benchmark test_name)
target_link_libraries(${test_name} libirritator threads)
endfunction()
if (NOT BUILD_SHARED_LIBS)
irritator_add_test(test-api test/public-api.cpp)
irritator_add_test(simulations test/simulations.cpp)
irritator_add_test(auditory test/auditory.cpp)
irritator_add_test(test-api test/public-api.cpp)
irritator_add_test(simulations test/simulations.cpp)
irritator_add_test(auditory test/auditory.cpp)
irritator_add_benchmark(benchmark_exactitude_aqss benchmark/benchmark_exactitude_aqss.cpp)
irritator_add_benchmark(benchmark_exactitude_qss1 benchmark/benchmark_exactitude_qss1.cpp)
irritator_add_benchmark(benchmark_exactitude_qss2 benchmark/benchmark_exactitude_qss2.cpp)
irritator_add_benchmark(benchmark_exactitude_aqss benchmark/benchmark_exactitude_aqss.cpp)
irritator_add_benchmark(benchmark_exactitude_qss1 benchmark/benchmark_exactitude_qss1.cpp)
irritator_add_benchmark(benchmark_exactitude_qss2 benchmark/benchmark_exactitude_qss2.cpp)
irritator_add_benchmark(benchmark_timing_qss1 benchmark/benchmark_timing_qss1.cpp)
irritator_add_benchmark(benchmark_timing_qss2 benchmark/benchmark_timing_qss2.cpp)
irritator_add_benchmark(benchmark_timing_aqss benchmark/benchmark_timing_aqss.cpp)
endif ()
irritator_add_benchmark(benchmark_timing_qss1 benchmark/benchmark_timing_qss1.cpp)
irritator_add_benchmark(benchmark_timing_qss2 benchmark/benchmark_timing_qss2.cpp)
irritator_add_benchmark(benchmark_timing_aqss benchmark/benchmark_timing_aqss.cpp)
@PACKAGE_INIT@
check_required_components(Irritator)
......@@ -7,7 +7,4 @@ Name: irritator
Description: A discrete event simulation tools
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
URL: http://www.vle-project.org/irritator
Requires: @IRRITATOR_DEPENDENCIES@
Cflags: -I${includedir}/irritator-@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@
Libs: -L${libdir} -lirritator-@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@
Libs.private:
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {} // namespace irritator
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {
class coupled
{
public:
};
} // namespace irt
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {
template<typename Time>
struct model_generator
{
output_port_id y[1];
Time sigma;
status initialize(simulation& /*sim*/)
{
sigma = 1;
return status::success;
}
status lambda(simulation& sim)
{
if (auto* port = sim.output_ports.try_to_get(y[0]); port)
port->messages.emplace_front(0.0);
return status::success;
}
};
} // namespace irt
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment