Skip to content

Commit

Permalink
Modernize CMakeLists.txt ECFLOW-1923
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento authored Nov 13, 2023
2 parents a300b98 + aa7c5f8 commit 3fca261
Show file tree
Hide file tree
Showing 50 changed files with 2,840 additions and 2,201 deletions.
216 changes: 161 additions & 55 deletions ACore/CMakeLists.txt
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/AssertTimer.hpp
src/Cal.hpp
src/Calendar.hpp
src/CalendarUpdateParams.hpp
src/CheckPt.hpp
src/Child.hpp
src/CommandLine.hpp
src/DState.hpp
src/DebugPerf.hpp
src/DurationTimer.hpp
src/Ecf.hpp
src/EcfPortLock.hpp
src/Extract.hpp
src/File.hpp
src/File_r.hpp
src/Host.hpp
src/Indentor.hpp
src/Log.hpp
src/LogVerification.hpp
src/NOrder.hpp
src/NState.hpp
src/NodePath.hpp
src/Passwd.hpp
src/PasswdFile.hpp
src/PasswordEncryption.hpp
src/Pid.hpp
src/PrintStyle.hpp
src/SState.hpp
src/Serialization.hpp
src/SerializationTest.hpp
src/Stl.hpp
src/Str.hpp
src/StringSplitter.hpp
src/TestUtil.hpp
src/TimeSeries.hpp
src/TimeSlot.hpp
src/TimeStamp.hpp
src/User.hpp
src/Version.hpp
src/WhiteListFile.hpp
src/cereal_boost_time.hpp
src/cereal_optional_nvp.hpp
src/perf_timer.hpp
# Sources
src/AssertTimer.cpp
src/Cal.cpp
src/Calendar.cpp
src/Child.cpp
src/CommandLine.cpp
src/DState.cpp
src/DurationTimer.cpp
src/Ecf.cpp
src/Extract.cpp
src/File.cpp
src/File_r.cpp
src/Host.cpp
src/Indentor.cpp
src/Log.cpp
src/LogVerification.cpp
src/NOrder.cpp
src/NState.cpp
src/NodePath.cpp
src/Passwd.cpp
src/PasswdFile.cpp
src/Pid.cpp
src/PrintStyle.cpp
src/SState.cpp
src/Str.cpp
src/StringSplitter.cpp
src/TimeSeries.cpp
src/TimeSlot.cpp
src/TimeStamp.cpp
src/User.cpp
src/Version.cpp
src/WhiteListFile.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/TestCalendar.cpp
test/TestCereal.cpp
test/TestCerealOptionalNVP.cpp
test/TestCerealWithHierarchy.cpp
test/TestClassDataMemberInit.cpp
test/TestCommandLine.cpp
test/TestCore_main.cpp # contains main() function for test driver
test/TestFile.cpp
test/TestGetUserDetails.cpp
test/TestLog.cpp
test/TestMigration.cpp
test/TestNodePath.cpp
test/TestPasswdFile.cpp
test/TestPasswordEncryption.cpp
test/TestPerfTimer.cpp
test/TestRealCalendar.cpp
test/TestSanitizerAS.cpp
test/TestSanitizerUB.cpp
test/TestSerialisation.cpp
test/TestStackTrace.cpp
test/TestStr.cpp
test/TestStringSplitPerf.cpp
test/TestStringSplitter.cpp
test/TestTimeSeries.cpp
test/TestTimeSlot.cpp
test/TestVersion.cpp
test/TestVersioning.cpp
test/TestWhiteListFile.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
)
16 changes: 0 additions & 16 deletions ACore/src/ecflow_version.h

This file was deleted.

12 changes: 12 additions & 0 deletions ACore/test/TestCore_main.cpp
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>
1 change: 1 addition & 0 deletions ACore/test/TestFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// #define FILE_PERF_CHECK_IMPLEMENTATIONS 1;
#ifdef FILE_PERF_CHECK_IMPLEMENTATIONS
#include <boost/timer/timer.hpp>
#include "Str.hpp"
#endif

#include "File.hpp"
Expand Down
1 change: 0 additions & 1 deletion ACore/test/TestNodePath.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define BOOST_TEST_MODULE TestCore
//============================================================================
// Name : Request
// Author : Avi
Expand Down
114 changes: 90 additions & 24 deletions ANattr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,97 @@
# Note:
# If new src or test cpp files are added make sure you touch this file
#
file( GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp" "src/*.hpp" )
# 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.
#

ecbuild_add_library( TARGET nodeattr
NOINSTALL
TYPE STATIC
SOURCES ${srcs}
)

target_link_libraries(nodeattr PRIVATE core)
target_include_directories(nodeattr PUBLIC src
../ACore/src
${Boost_INCLUDE_DIRS})
set(srcs
# Headers
src/AutoArchiveAttr.hpp
src/AutoCancelAttr.hpp
src/ClockAttr.hpp
src/CronAttr.hpp
src/DateAttr.hpp
src/DayAttr.hpp
src/GenericAttr.hpp
src/LateAttr.hpp
src/NodeAttr.hpp
src/QueueAttr.hpp
src/RepeatAttr.hpp
src/TimeAttr.hpp
src/TodayAttr.hpp
src/Variable.hpp
src/VerifyAttr.hpp
src/Zombie.hpp
src/ZombieAttr.hpp
# Sources
src/AutoArchiveAttr.cpp
src/AutoCancelAttr.cpp
src/ClockAttr.cpp
src/CronAttr.cpp
src/DateAttr.cpp
src/DayAttr.cpp
src/GenericAttr.cpp
src/LateAttr.cpp
src/NodeAttr.cpp
src/QueueAttr.cpp
src/RepeatAttr.cpp
src/TimeAttr.cpp
src/TodayAttr.cpp
src/Variable.cpp
src/VerifyAttr.cpp
src/Zombie.cpp
src/ZombieAttr.cpp
)

ecbuild_add_library(
TARGET
nodeattr
NOINSTALL
TYPE STATIC
SOURCES
${srcs}
PUBLIC_INCLUDES
src
PUBLIC_LIBS
core
Boost::date_time
)
target_clangformat(nodeattr)


file( GLOB test_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "test/*.cpp" )

# libboost_unit_test_framework undefined reference to `clock_gettime', ${LIBRT} needed for boost 1.71
ecbuild_add_test( TARGET u_anattr
SOURCES ${test_srcs}
INCLUDES src ${Boost_INCLUDE_DIRS}
LIBS nodeattr ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_TEST_EXEC_MONITOR_LIBRARY} ${LIBRT}
DEFINITIONS ${BOOST_TEST_DYN_LINK}
TEST_DEPENDS u_acore
)
set(test_srcs
# Sources
test/TestAttributes_main.cpp
test/TestAttrSerialization.cpp
test/TestCron.cpp
test/TestDateAttr.cpp
test/TestDayAttr.cpp
test/TestLabel.cpp
test/TestLateAttr.cpp
test/TestMigration.cpp
test/TestRepeat.cpp
test/TestSizeOf.cpp
test/TestTimeAttr.cpp
test/TestTodayAttr.cpp
test/TestVariable.cpp
test/TestZombieAttr.cpp
)

target_clangformat(u_anattr CONDITION ENABLE_TESTS)
ecbuild_add_test(
TARGET
u_anattr
SOURCES
${test_srcs}
LIBS
nodeattr
TEST_DEPENDS
u_acore
Boost::boost # Boost header-only libraries must be available (namely unit_test_framework)
)
target_clangformat(u_anattr
CONDITION ENABLE_TESTS
)
2 changes: 0 additions & 2 deletions ANattr/test/TestAttrSerialization.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define BOOST_TEST_MODULE TestANattr

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// Name :
// Author : Avi
Expand Down
Loading

0 comments on commit 3fca261

Please sign in to comment.