-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move generated header files to CMAKE_BINARY_DIR to avoid having changes on the working directory (dirty repository) - Setup Boost.unit_test_framework as header only library - Create a specific entry point for the test driver - by convention, named Test<LibName>_main.cpp
- Loading branch information
1 parent
a300b98
commit f2d6c46
Showing
5 changed files
with
174 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,168 @@ | ||
# Note: | ||
# If new src or test is added make sure you touch this file | ||
# | ||
|
||
|
||
# crypt is not needed on Apple machines | ||
if(NOT DEFINED APPLE) | ||
set(CRYPT_LIB crypt) | ||
endif() | ||
|
||
# Only really needed for File.cpp | ||
add_definitions( -DCMAKE ) | ||
|
||
# We place generated file in /ACore/src/ so that we can still use boost build | ||
configure_file( ecflow_version.h.in ${CMAKE_SOURCE_DIR}/ACore/src/ecflow_version.h ) | ||
|
||
# place in binary directory since this is different for each user | ||
configure_file( ecflow_source_build_dir.h.in ${CMAKE_BINARY_DIR}/ecflow_source_build_dir.h ) | ||
|
||
# Use transitive nature: i.e if any lib/exe uses lib core, they | ||
# will also inherit the boost libs. | ||
# Copyright 2023- ECMWF. | ||
# | ||
file( GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp" "src/*.hpp" "src/*.h" ) | ||
ecbuild_add_library( TARGET core | ||
NOINSTALL | ||
TYPE STATIC | ||
SOURCES ${srcs} | ||
) | ||
target_include_directories(core PUBLIC src | ||
${Boost_INCLUDE_DIRS} | ||
${CMAKE_BINARY_DIR} ) | ||
# 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. | ||
# | ||
|
||
configure_file(ecflow_version.h.in ${CMAKE_BINARY_DIR}/generated/ecflow_version.h) | ||
configure_file(ecflow_source_build_dir.h.in ${CMAKE_BINARY_DIR}/generated/ecflow_source_build_dir.h) | ||
|
||
# This ensures that for debug config, we only link with debug boost libs, for other configs, we link with optimised boost libs | ||
if ( Boost_VERSION_STRING VERSION_LESS "1.69.0" ) | ||
target_link_libraries(core ${Boost_FILESYSTEM_LIBRARY_RELEASE} | ||
${Boost_DATE_TIME_LIBRARY_RELEASE} | ||
${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} | ||
${Boost_SYSTEM_LIBRARY_RELEASE} | ||
${CRYPT_LIB} | ||
) | ||
else() | ||
# for boost version 1.69 or greater Boost.System is now header-only. | ||
target_link_libraries(core ${Boost_FILESYSTEM_LIBRARY_RELEASE} | ||
${Boost_DATE_TIME_LIBRARY_RELEASE} | ||
${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} | ||
${CRYPT_LIB} | ||
) | ||
endif() | ||
set(srcs | ||
# Headers | ||
${CMAKE_BINARY_DIR}/generated/ecflow_version.h | ||
${CMAKE_BINARY_DIR}/generated/ecflow_source_build_dir.h | ||
src/TimeStamp.hpp | ||
src/TimeSlot.hpp | ||
src/TestUtil.hpp | ||
src/StringSplitter.hpp | ||
src/PasswdFile.hpp | ||
src/NodePath.hpp | ||
src/perf_timer.hpp | ||
src/CommandLine.hpp | ||
src/Host.hpp | ||
src/Str.hpp | ||
src/Extract.hpp | ||
src/AssertTimer.hpp | ||
src/PrintStyle.hpp | ||
src/CheckPt.hpp | ||
src/Ecf.hpp | ||
src/File.hpp | ||
src/SState.hpp | ||
src/Serialization.hpp | ||
src/NOrder.hpp | ||
src/File_r.hpp | ||
src/Cal.hpp | ||
src/WhiteListFile.hpp | ||
src/User.hpp | ||
src/PasswordEncryption.hpp | ||
src/Version.hpp | ||
src/DurationTimer.hpp | ||
src/cereal_optional_nvp.hpp | ||
src/DebugPerf.hpp | ||
src/Indentor.hpp | ||
src/Calendar.hpp | ||
src/LogVerification.hpp | ||
src/DState.hpp | ||
src/NState.hpp | ||
src/EcfPortLock.hpp | ||
src/Log.hpp | ||
src/Passwd.hpp | ||
src/SerializationTest.hpp | ||
src/cereal_boost_time.hpp | ||
src/Pid.hpp | ||
src/Child.hpp | ||
src/Stl.hpp | ||
src/TimeSeries.hpp | ||
src/CalendarUpdateParams.hpp | ||
# Sources | ||
src/DState.cpp | ||
src/NState.cpp | ||
src/Log.cpp | ||
src/Passwd.cpp | ||
src/Child.cpp | ||
src/Pid.cpp | ||
src/TimeSeries.cpp | ||
src/Version.cpp | ||
src/DurationTimer.cpp | ||
src/Indentor.cpp | ||
src/Calendar.cpp | ||
src/LogVerification.cpp | ||
src/PrintStyle.cpp | ||
src/File.cpp | ||
src/Ecf.cpp | ||
src/SState.cpp | ||
src/NOrder.cpp | ||
src/File_r.cpp | ||
src/WhiteListFile.cpp | ||
src/Cal.cpp | ||
src/User.cpp | ||
src/TimeStamp.cpp | ||
src/TimeSlot.cpp | ||
src/StringSplitter.cpp | ||
src/PasswdFile.cpp | ||
src/NodePath.cpp | ||
src/CommandLine.cpp | ||
src/Str.cpp | ||
src/Host.cpp | ||
src/Extract.cpp | ||
src/AssertTimer.cpp | ||
) | ||
|
||
ecbuild_add_library( | ||
TARGET | ||
core | ||
NOINSTALL | ||
TYPE STATIC | ||
SOURCES | ||
${srcs} | ||
PUBLIC_INCLUDES | ||
src | ||
${CMAKE_BINARY_DIR}/generated | ||
PUBLIC_LIBS | ||
$<$<VERSION_LESS:${Boost_VERSION},1.69.0>:Boost::system> | ||
Boost::filesystem | ||
Boost::date_time | ||
Boost::program_options | ||
$<$<NOT:$<BOOL:${APPLE}>>:crypt> | ||
DEFINITIONS | ||
CMAKE | ||
) | ||
target_clangformat(core) | ||
|
||
# ${LIBRT} See: https://stackoverflow.com/questions/13653361/another-undefined-reference-error-when-linking-boost-libraries | ||
file( GLOB test_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "test/*.cpp" "test/*.hpp" ) | ||
ecbuild_add_test( TARGET u_acore | ||
SOURCES ${test_srcs} | ||
INCLUDES src ${Boost_INCLUDE_DIRS} | ||
LIBS core ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_TEST_EXEC_MONITOR_LIBRARY} | ||
${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY} ${LIBRT} | ||
DEFINITIONS ${BOOST_TEST_DYN_LINK} | ||
) | ||
set(test_srcs | ||
# Headers | ||
test/TestVersioning.hpp | ||
# Sources | ||
test/TestCore_main.cpp # contains main() function for test driver | ||
test/TestCalendar.cpp | ||
test/TestSanitizerUB.cpp | ||
test/TestSanitizerAS.cpp | ||
test/TestStringSplitter.cpp | ||
test/TestFile.cpp | ||
test/TestWhiteListFile.cpp | ||
test/TestStr.cpp | ||
test/TestPasswordEncryption.cpp | ||
test/TestVersion.cpp | ||
test/TestPasswdFile.cpp | ||
test/TestVersioning.cpp | ||
test/TestTimeSeries.cpp | ||
test/TestCerealWithHierarchy.cpp | ||
test/TestLog.cpp | ||
test/TestGetUserDetails.cpp | ||
test/TestNodePath.cpp | ||
test/TestClassDataMemberInit.cpp | ||
test/TestStringSplitPerf.cpp | ||
test/TestCommandLine.cpp | ||
test/TestTimeSlot.cpp | ||
test/TestSerialisation.cpp | ||
test/TestRealCalendar.cpp | ||
test/TestStackTrace.cpp | ||
test/TestPerfTimer.cpp | ||
test/TestMigration.cpp | ||
test/TestCerealOptionalNVP.cpp | ||
test/TestCereal.cpp | ||
) | ||
|
||
target_clangformat(u_acore CONDITION ENABLE_TESTS) | ||
ecbuild_add_test( | ||
TARGET | ||
u_acore | ||
SOURCES | ||
${test_srcs} | ||
LIBS | ||
core | ||
Boost::boost # Boost header-only libraries must be available (namely unit_test_framework) | ||
# | ||
# Important! | ||
# | ||
# Boost::timer, Boost::chrono are required when certain definitions are manually turned on, e.g. | ||
# - FILE_PERF_CHECK_IMPLEMENTATIONS, at TestFile.cpp | ||
# - STRING_SPLIT_IMPLEMENTATIONS_PERF_CHECK_, at TestStringSplitPerf.cpp | ||
# | ||
) | ||
target_clangformat(u_acore | ||
CONDITION ENABLE_TESTS | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#define BOOST_TEST_MODULE TestCore | ||
#include <boost/test/included/unit_test.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters