Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: CMake compiler_definitions inconsistent with jana_config.h #313

Merged
merged 12 commits into from
Jul 12, 2024
Merged
26 changes: 17 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,22 @@ option(USE_CUDA "Compile CUDA-involved examples (Needed for examples/SubeventCUD
option(USE_PODIO "Compile with PODIO support" OFF)
option(BUILD_SHARED_LIBS "Build into both shared and static libs." ON)

if (${USE_PODIO})
find_package(podio REQUIRED)
set(JANA2_HAVE_PODIO 1)
set(USE_ROOT ON)
include_directories(SYSTEM ${podio_INCLUDE_DIR})
else()
set(JANA2_HAVE_PODIO 0)
endif()


if (${USE_ROOT})
if((NOT DEFINED ROOT_DIR) AND (DEFINED ENV{ROOTSYS}))
set(ROOT_DIR $ENV{ROOTSYS}/cmake)
endif()
find_package(ROOT REQUIRED)
include(${ROOT_USE_FILE})
add_compile_definitions(JANA2_HAVE_ROOT)
set(JANA2_HAVE_ROOT 1)
include_directories(${ROOT_INCLUDE_DIRS})
link_libraries(${ROOT_LIBRARIES})
execute_process(
Expand All @@ -90,6 +98,8 @@ if (${USE_ROOT})
"Specify the C++ standard used to compile ROOT with e.g. -DCMAKE_CXX_STANDARD=17. "
"Check the root-config output above for cxx flags.")
endif()
else()
set(JANA2_HAVE_ROOT 0)
endif()

if (${USE_ZEROMQ})
Expand All @@ -101,10 +111,11 @@ if (${USE_XERCES})
set(XercesC_DIR $ENV{XERCESCROOT})
endif()
find_package(XercesC REQUIRED)
add_compile_definitions(JANA2_HAVE_XERCES)
add_compile_definitions(XERCES3)
set(JANA2_HAVE_XERCES 1)
include_directories(${XercesC_INCLUDE_DIRS})
link_libraries(${XercesC_LIBRARIES})
else()
set(JANA2_HAVE_XERCES 0)
endif()

if (${USE_ASAN})
Expand All @@ -121,11 +132,6 @@ if (${USE_CUDA})
find_package(CUDA REQUIRED)
endif()

if (${USE_PODIO})
find_package(podio REQUIRED)
add_compile_definitions(JANA2_HAVE_PODIO)
include_directories(SYSTEM ${podio_INCLUDE_DIR})
endif()

#---------
# Report back to the user what we've discovered
Expand Down Expand Up @@ -188,6 +194,7 @@ message(STATUS "-----------------------")

include_directories(src/libraries) # So that everyone can find the JANA header files
include_directories(src/external) # So that everyone can find our vendorized header-old libraries
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libraries) # So that everyone can find JVersion.h

# This is needed on macos to allow plugins to link without resolving all JANA symbols until runtime
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
Expand All @@ -208,3 +215,4 @@ add_subdirectory(src/python)
install(DIRECTORY scripts/ DESTINATION bin FILES_MATCHING PATTERN "jana-*.py"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
include(${CMAKE_SOURCE_DIR}/cmake/MakeConfig.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/MakeJVersionH.cmake)
73 changes: 36 additions & 37 deletions cmake/MakeConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# This is used in the generation of the files:
# jana-config
# jana_config.h
# jana-this.sh
# jana-this.csh
#
Expand All @@ -25,46 +24,51 @@ execute_process(COMMAND SBMS/osrelease.pl
OUTPUT_STRIP_TRAILING_WHITESPACE)

# ROOT
if(DEFINED ENV{ROOTSYS})
set(JANA2_HAVE_ROOT 1)
set(ROOTSYS $ENV{ROOTSYS})

execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --cflags
OUTPUT_VARIABLE ROOTCFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --glibs
OUTPUT_VARIABLE ROOTGLIBS
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
if(${USE_ROOT})
if(DEFINED ENV{ROOTSYS})
set(JANA2_HAVE_ROOT 1)
set(ROOTSYS $ENV{ROOTSYS})

execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --cflags
OUTPUT_VARIABLE ROOTCFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --glibs
OUTPUT_VARIABLE ROOTGLIBS
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
# message(STATUS "Did not find ROOT")
set(JANA2_HAVE_ROOT 0)
endif()
else()
set(JANA2_HAVE_ROOT 0)
endif()

# XERCESC
# n.b. this is hard-coded for now to assume XERCES 3
if(DEFINED ENV{XERCESCROOT})
set(JANA2_HAVE_XERCES 1)
set(XERCES3 1)
set(XERCESCROOT $ENV{XERCESCROOT})
set(XERCES_CPPFLAGS "-I${XERCESCROOT}/include/xercesc")
set(XERCES_LIBS "-lxerces-c")
if( NOT $XERCESCROOT EQUAL "/usr" )
set(XERCES_CPPFLAGS "${XERCES_CPPFLAGS} -I${XERCESCROOT}/include")
set(XERCES_LDFLAGS "-L${XERCESCROOT}/lib")
endif()
else()
find_package(XercesC)
if(XercesC_FOUND)
if(${USE_XERCES})
if(DEFINED ENV{XERCESCROOT})
set(JANA2_HAVE_XERCES 1)
set(XERCES3 1)
get_filename_component(XERCESCROOT "${XercesC_INCLUDE_DIRS}" DIRECTORY)
set(XERCES_CPPFLAGS "-I${XercesC_INCLUDE_DIRS} -I${XercesC_INCLUDE_DIRS}/xercesc")
set(XERCES_LIBS "${XercesC_LIBRARIES}")
set(XERCESCROOT $ENV{XERCESCROOT})
set(XERCES_CPPFLAGS "-I${XERCESCROOT}/include/xercesc")
set(XERCES_LIBS "-lxerces-c")
if( NOT $XERCESCROOT EQUAL "/usr" )
set(XERCES_CPPFLAGS "${XERCES_CPPFLAGS} -I${XERCESCROOT}/include")
set(XERCES_LDFLAGS "-L${XERCESCROOT}/lib")
endif()
else()
set(JANA2_HAVE_XERCES 0)
set(XERCES3 0)
find_package(XercesC)
if(XercesC_FOUND)
set(JANA2_HAVE_XERCES 1)
get_filename_component(XERCESCROOT "${XercesC_INCLUDE_DIRS}" DIRECTORY)
set(XERCES_CPPFLAGS "-I${XercesC_INCLUDE_DIRS} -I${XercesC_INCLUDE_DIRS}/xercesc")
set(XERCES_LIBS "${XercesC_LIBRARIES}")
else()
set(JANA2_HAVE_XERCES 0)
endif()
endif()
else()
set(JANA2_HAVE_XERCES 0)
endif()

# cMsg
Expand Down Expand Up @@ -140,15 +144,10 @@ else()
set(HAVE_CURL 0)
endif()

# TODO: FindNuma.cmake
set(HAVE_NUMA 0)

configure_file(scripts/jana-config.in jana-config @ONLY)
configure_file(scripts/jana_config.h.in src/libraries/JANA/jana_config.h @ONLY)
configure_file(scripts/jana-this.sh.in jana-this.sh @ONLY)
configure_file(scripts/jana-this.csh.in jana-this.csh @ONLY)

install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-config DESTINATION bin)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/jana_config.h DESTINATION include/JANA)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.csh DESTINATION bin)
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ else()
endif()

message(STATUS "Generating JVersion.h")
configure_file(JVersion.h.in JVersion.h)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/JVersion.h DESTINATION include/JANA/CLI)
configure_file(src/libraries/JANA/JVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h DESTINATION include/JANA)
10 changes: 0 additions & 10 deletions scripts/jana_config.h.in

This file was deleted.

2 changes: 0 additions & 2 deletions src/examples/RootDatamodelExample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

if(${USE_ROOT})
find_package(ROOT REQUIRED)
include(${ROOT_USE_FILE})

# Generate ROOT dictionaries for each of our ROOT object types
# The foreach statement below should end with a list of classes
Expand Down Expand Up @@ -34,7 +33,6 @@ if(${USE_ROOT})
)

add_library(RootDatamodelExample_plugin SHARED ${RootDatamodelExample_PLUGIN_SOURCES})
target_compile_definitions(RootDatamodelExample_plugin PUBLIC JANA2_HAVE_ROOT)
target_include_directories(RootDatamodelExample_plugin PUBLIC ${JANA_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS})
target_link_libraries(RootDatamodelExample_plugin jana2)
target_link_libraries(RootDatamodelExample_plugin ${ROOT_LIBRARIES})
Expand Down
8 changes: 1 addition & 7 deletions src/libraries/JANA/CLI/JMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

#include "JMain.h"

#include <JANA/CLI/JVersion.h>
#include <JANA/JVersion.h>
#include <JANA/CLI/JBenchmarker.h>
#include <JANA/CLI/JSignalHandler.h>

// The values of JVERSION_COMMIT_HASH and JVERSION_COMMIT_DATE
// are #defined in JVersion.h.in so cmake can set them.
const std::string JVersion::last_commit_hash = JVERSION_COMMIT_HASH;
const std::string JVersion::last_commit_date = JVERSION_COMMIT_DATE;
const std::string JVersion::installdir = CMAKE_INSTALL_PREFIX;


namespace jana {

Expand Down
8 changes: 8 additions & 0 deletions src/libraries/JANA/CLI/JVersion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// We are moving JVersion.h out of CLI.
// In the future, use #include <JANA/JVersion.h> instead.

#include <JANA/JVersion.h>


13 changes: 1 addition & 12 deletions src/libraries/JANA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

# For now all the CMakeLists in 'CLI' does is generate and install JVersion.h
add_subdirectory(CLI)

# Everything else happens below
set(JANA2_SOURCES
Expand Down Expand Up @@ -127,8 +125,6 @@ set(JANA2_SOURCES
Compatibility/JGeometry.h
Compatibility/JGeometryManager.cc
Compatibility/JGeometryManager.h
Compatibility/JGeometryMYSQL.cc
Compatibility/JGeometryMYSQL.h
Compatibility/JGeometryXML.cc
Compatibility/JGeometryXML.h
Compatibility/md5.c
Expand All @@ -152,14 +148,11 @@ add_library(jana2 OBJECT ${JANA2_SOURCES})

find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
target_include_directories(jana2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..)
# So that we can find the generated JVersion.h before install
target_link_libraries(jana2 ${CMAKE_DL_LIBS} Threads::Threads)

if (${USE_PODIO})
target_compile_definitions(jana2 PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1)
target_link_libraries(jana2 podio::podio podio::podioRootIO ${ROOT_LIBRARIES})
elseif (${USE_ROOT})
target_compile_definitions(jana2 PUBLIC JANA2_HAVE_ROOT=1)
target_link_libraries(jana2 ${ROOT_LIBRARIES})
endif()

Expand All @@ -172,10 +165,8 @@ target_include_directories(jana2_static_lib PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries(jana2_static_lib ${CMAKE_DL_LIBS} Threads::Threads)

if (${USE_PODIO})
target_compile_definitions(jana2_static_lib PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1)
target_link_libraries(jana2_static_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES})
elseif (${USE_ROOT})
target_compile_definitions(jana2_static_lib PUBLIC JANA2_HAVE_ROOT=1)
target_link_libraries(jana2_static_lib ${ROOT_LIBRARIES})
endif()
install(TARGETS jana2_static_lib EXPORT jana2_targets DESTINATION lib)
Expand All @@ -191,10 +182,8 @@ if (BUILD_SHARED_LIBS)
target_link_libraries(jana2_shared_lib ${CMAKE_DL_LIBS} Threads::Threads)

if (${USE_PODIO})
target_compile_definitions(jana2_shared_lib PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1)
target_link_libraries(jana2_shared_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES})
elseif (${USE_ROOT})
target_compile_definitions(jana2_shared_lib PUBLIC JANA2_HAVE_ROOT=1)
target_link_libraries(jana2_shared_lib ${ROOT_LIBRARIES})
endif()

Expand Down
67 changes: 0 additions & 67 deletions src/libraries/JANA/Compatibility/JGeometryMYSQL.cc

This file was deleted.

33 changes: 0 additions & 33 deletions src/libraries/JANA/Compatibility/JGeometryMYSQL.h

This file was deleted.

Loading
Loading