Skip to content

Commit 72e25f6

Browse files
authored
Create a new target to copy the files after all the other targets (#326)
1 parent b29c25d commit 72e25f6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

test/k4FWCoreTest/CMakeLists.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ gaudi_add_module(k4FWCoreTestPlugins
5454
SOURCES ${k4fwcoretest_plugin_sources}
5555
LINK Gaudi::GaudiKernel k4FWCore k4FWCore::k4Interface ROOT::Core ROOT::RIO ROOT::Tree podio::podioIO EDM4HEP::edm4hep)
5656

57-
include(CTest)
58-
5957
set(K4RUN ${PROJECT_SOURCE_DIR}/k4FWCore/scripts/k4run)
6058

6159
function(set_test_env testname)
@@ -64,6 +62,19 @@ function(set_test_env testname)
6462
set_property(TEST ${testname} APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/${PROJECT_NAME}/genConfDir:${PROJECT_BINARY_DIR}/test/k4FWCoreTest/genConfDir:$ENV{PYTHONPATH}")
6563
endfunction()
6664

65+
66+
# The following is done to make the tests work without installing the files in
67+
# the installation directory. The k4FWCore in the build directory is populated by
68+
# Gaudi so we can't just make a k4FWCore folder and put the python files there.
69+
# We put everything in one of the folders generated by Gaudi so that importing from
70+
# k4FWCore will give the right result
71+
add_custom_target(copy_directory ALL
72+
COMMAND ${CMAKE_COMMAND} -E copy_directory
73+
${PROJECT_SOURCE_DIR}/python/k4FWCore/ ${PROJECT_BINARY_DIR}/k4FWCore/genConfDir/k4FWCore
74+
COMMENT "Copying k4FWCore python package after building all the libraries and plugins"
75+
DEPENDS k4FWCoreTestPlugins k4FWCore k4FWCorePlugins
76+
)
77+
6778
#[[
6879
add_test_with_env
6980
-----------------
@@ -234,15 +245,6 @@ add_test_with_env(ReadLimitedInputsAllEventsIOSvc options/ExampleIOSvcLimitInput
234245
add_test_with_env(ParticleIDMetadataFramework options/ExampleParticleIDMetadata.py)
235246

236247

237-
# The following is done to make the tests work without installing the files in
238-
# the installation directory. The k4FWCore in the build directory is populated by
239-
# Gaudi so we can't just make a k4FWCore folder and put the python files there.
240-
# We put everything in one of the folders generated by Gaudi so that importing from
241-
# k4FWCore will give the right result
242-
add_custom_command(TARGET k4FWCoreTestPlugins POST_BUILD
243-
COMMAND ${CMAKE_COMMAND} -E copy_directory
244-
${PROJECT_SOURCE_DIR}/python/k4FWCore/ ${PROJECT_BINARY_DIR}/k4FWCore/genConfDir/k4FWCore)
245-
246248
add_executable(check_ParticleIDOutputs src/check_ParticleIDOutputs.cpp)
247249
target_link_libraries(check_ParticleIDOutputs PRIVATE podio::podioIO EDM4HEP::edm4hep EDM4HEP::utils fmt::fmt)
248250
add_test(NAME check_ParticleIDOutputs COMMAND check_ParticleIDOutputs example_with_particleids.root)

0 commit comments

Comments
 (0)