Skip to content

Commit

Permalink
Modernize CMakeLists.txt for Simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento committed Nov 13, 2023
1 parent af78c6a commit d4214b5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 66 deletions.
141 changes: 79 additions & 62 deletions CSim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,72 +1,89 @@
list( APPEND srcs
# HEADERS
src/Analyser.hpp
src/AstAnalyserVisitor.hpp
src/DefsAnalyserVisitor.hpp
src/FlatAnalyserVisitor.hpp
src/Simulator.hpp
src/SimulatorVisitor.hpp
# SOURCES
src/Analyser.cpp
src/AstAnalyserVisitor.cpp
src/DefsAnalyserVisitor.cpp
src/FlatAnalyserVisitor.cpp
src/Simulator.cpp
src/SimulatorVisitor.cpp
)
ecbuild_add_library( TARGET libsimu
NOINSTALL
TYPE STATIC
SOURCES ${srcs}
)
#
# Copyright 2023- ECMWF.
#
# This software is licensed under the terms of the Apache Licence version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
#

target_link_libraries(libsimu node nodeattr core)
target_include_directories(libsimu PUBLIC src
../ACore/src
../ANattr/src
../ANode/src
../Base/src
)
find_package(Threads REQUIRED)

set(srcs
# Headers
src/Analyser.hpp
src/AstAnalyserVisitor.hpp
src/DefsAnalyserVisitor.hpp
src/FlatAnalyserVisitor.hpp
src/Simulator.hpp
src/SimulatorVisitor.hpp
# Sources
src/Analyser.cpp
src/AstAnalyserVisitor.cpp
src/DefsAnalyserVisitor.cpp
src/FlatAnalyserVisitor.cpp
src/Simulator.cpp
src/SimulatorVisitor.cpp
)
ecbuild_add_library(
TARGET
libsimu
NOINSTALL
TYPE STATIC
SOURCES
${srcs}
PUBLIC_INCLUDES
src
PUBLIC_LIBS
node
nodeattr
core
)
target_clangformat(libsimu)

list( APPEND test_srcs
# HEADERS
test/TestUtil.hpp
# SOURCES
test/TestAutoArchive.cpp
test/TestAutoCancel.cpp
test/TestAutoRestore.cpp
test/TestMeter.cpp
test/TestTime.cpp
test/TestUtil.cpp
test/TestSimulator.cpp
test/TestAutoCancel.cpp
test/TestRepeat.cpp
test/TestToday.cpp
test/TestAnalysis.cpp
set(test_srcs
# Headers
test/TestUtil.hpp
# Sources
test/TestAnalysis.cpp
test/TestAutoArchive.cpp
test/TestAutoCancel.cpp
test/TestAutoCancel.cpp
test/TestAutoRestore.cpp
test/TestMeter.cpp
test/TestRepeat.cpp
test/TestSimulator.cpp
test/TestTime.cpp
test/TestToday.cpp
test/TestUtil.cpp
)
ecbuild_add_test(
TARGET
c_csim
SOURCES
${test_srcs}
LIBS
libsimu
Threads::Threads
TEST_DEPENDS u_base
)
ecbuild_add_test( TARGET c_csim
SOURCES ${test_srcs}
LIBS libsimu
pthread
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_TEST_EXEC_MONITOR_LIBRARY} ${LIBRT}
INCLUDES ../ANode/test ${Boost_INCLUDE_DIRS}
DEFINITIONS ${BOOST_TEST_DYN_LINK}
TEST_DEPENDS u_base
)

target_clangformat(c_csim CONDITION ENABLE_TESTS)

if (ENABLE_ALL_TESTS)
ecbuild_add_test( TARGET c_csim_single
SOURCES test/TestSingleSimulator.cpp test/TestUtil.cpp
LIBS libsimu
pthread
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_TEST_EXEC_MONITOR_LIBRARY} ${LIBRT}
INCLUDES ../ANode/test ${Boost_INCLUDE_DIRS}
DEFINITIONS ${BOOST_TEST_DYN_LINK}
TEST_DEPENDS u_base
)

ecbuild_add_test(
TARGET
c_csim_single
SOURCES
test/TestSingleSimulator.cpp
test/TestUtil.cpp
LIBS
libsimu
Threads::Threads
TEST_DEPENDS
u_base
)
target_clangformat(c_csim_single CONDITION ENABLE_TESTS)

endif()
4 changes: 2 additions & 2 deletions CSim/test/TestSimulator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define BOOST_TEST_MODULE TestSimulator
//============================================================================
// Name :
// Author : Avi
Expand All @@ -19,7 +18,8 @@

#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/test/unit_test.hpp>
#define BOOST_TEST_MODULE TestSimulator
#include <boost/test/included/unit_test.hpp>

#include "File.hpp"
#include "Simulator.hpp"
Expand Down
4 changes: 2 additions & 2 deletions CSim/test/TestSingleSimulator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define BOOST_TEST_MODULE TestSingleSimulator
//============================================================================
// Name :
// Author : Avi
Expand All @@ -23,7 +22,8 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/test/unit_test.hpp>
#define BOOST_TEST_MODULE TestSingleSimulator
#include <boost/test/included/unit_test.hpp>

#include "Defs.hpp"
#include "Family.hpp"
Expand Down

0 comments on commit d4214b5

Please sign in to comment.