Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release")
endif()

if (CMAKE_BUILD_TYPE MATCHES "^((p|P)(rofile|rof))|(release)$")
if (CMAKE_BUILD_TYPE MATCHES "^((p|P)(rofile|rof))|(release)|(RelWithDebInfo)$")
message(STATUS "Setting build type to 'Release' instead of '${CMAKE_BUILD_TYPE}'.")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE)
Expand Down Expand Up @@ -55,7 +55,7 @@ find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE _build_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down Expand Up @@ -197,8 +197,12 @@ add_subdirectory(Tests)


install(TARGETS General Trajectory Geometry Detector Fit MatEnv Examples
EXPORT KinKalTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# install headers
# Globbing here is fine because it does not influence build behaviour
Expand Down Expand Up @@ -234,4 +238,30 @@ export KINKAL_LIBRARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/lib

")


# Set up CMake exports for find_package
set(KinKal_IN_TREE TRUE CACHE BOOL "Whether KinKal is in the current tree")
include(CMakePackageConfigHelpers)
install(EXPORT KinKalTargets
FILE KinKalTargets.cmake
NAMESPACE KinKal::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake
)

write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)

install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)

export(EXPORT KinKalTargets
FILE "${PROJECT_BINARY_DIR}/KinKalTargets.cmake"
NAMESPACE KinKal::
)
4 changes: 3 additions & 1 deletion Detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ add_library(Detector SHARED

#message( "source dir detector " ${CMAKE_SOURCE_DIR}/..)
# set top-level directory as include root
target_include_directories(Detector PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Detector PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link this library with ROOT libraries and other KinKal libraries
target_link_libraries(Detector Trajectory General ${ROOT_LIBRARIES})
Expand Down
4 changes: 3 additions & 1 deletion Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ add_library(Examples SHARED
StrawMaterial.cc
ExamplesDict
)
target_include_directories(Examples PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Examples PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(Examples PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link ROOT libraries
target_link_libraries(Examples ${ROOT_LIBRARIES})
Expand Down
28 changes: 0 additions & 28 deletions FindKinKal.cmake

This file was deleted.

4 changes: 3 additions & 1 deletion Fit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ add_library(Fit SHARED
)

# set top-level directory as include root
target_include_directories(Fit PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Fit PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link this library with ROOT libraries
target_link_libraries(Fit Detector Trajectory General ${ROOT_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion Fit/Track.hh
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ namespace KinKal {
// find the range of existing ptraj pieces that overlaps with this domain's range
using KTRAJPTR = std::shared_ptr<KTRAJ>;
using DKTRAJ = std::deque<KTRAJPTR>;
using DKTRAJCITER = DKTRAJ::const_iterator;
using DKTRAJCITER = typename DKTRAJ::const_iterator;
DKTRAJCITER first,last;
fittraj_->pieceRange(domain->range(),first,last);
// loop over these pieces
Expand Down
4 changes: 3 additions & 1 deletion General/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ ROOT_GENERATE_DICTIONARY(GeneralDict
)

# set top-level directory as include root
target_include_directories(General PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(General PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link this library with ROOT libraries
target_link_libraries(General ${ROOT_LIBRARIES})
Expand Down
4 changes: 3 additions & 1 deletion Geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ add_library(Geometry SHARED
set(CMAKE_SHARED_LIBRARY_PREFIX "libKinKal_")

# set top-level directory as include root
target_include_directories(Geometry PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Geometry PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link this library with ROOT libraries
target_link_libraries(Geometry General ${ROOT_LIBRARIES})
Expand Down
4 changes: 3 additions & 1 deletion MatEnv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ add_library(MatEnv SHARED
)

# set top-level directory as include root
target_include_directories(MatEnv PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(MatEnv PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# set shared library version equal to project version
set_target_properties(MatEnv PROPERTIES VERSION ${PROJECT_VERSION} PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
4 changes: 3 additions & 1 deletion Trajectory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ ROOT_GENERATE_DICTIONARY(TrajectoryDict
)

# set top-level directory as include root
target_include_directories(Trajectory PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Trajectory PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)

# link this library with ROOT libraries
target_link_libraries(Trajectory Geometry General ${ROOT_LIBRARIES})
Expand Down
12 changes: 6 additions & 6 deletions Trajectory/PiecewiseTrajectory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace KinKal {
public:
using KTRAJPTR = std::shared_ptr<KTRAJ>;
using DKTRAJ = std::deque<KTRAJPTR>;
using DKTRAJITER = DKTRAJ::iterator;
using DKTRAJCITER = DKTRAJ::const_iterator;
using DKTRAJITER = typename DKTRAJ::iterator;
using DKTRAJCITER = typename DKTRAJ::const_iterator;
// forward calls to the pieces
VEC3 position3(double time) const { return nearestPiece(time).position3(time); }
VEC3 velocity(double time) const { return nearestPiece(time).velocity(time); }
Expand Down Expand Up @@ -283,8 +283,8 @@ namespace KinKal {
}

template <class KTRAJ> void PiecewiseTrajectory<KTRAJ>::pieceRange(TimeRange const& range,
std::deque<std::shared_ptr<KTRAJ>>::const_iterator& first,
std::deque<std::shared_ptr<KTRAJ>>::const_iterator& last ) const {
typename std::deque<std::shared_ptr<KTRAJ>>::const_iterator &first,
typename std::deque<std::shared_ptr<KTRAJ>>::const_iterator &last) const {
first = last = pieces_.end();
// check for no overlap
if(this->range().overlaps(range)){
Expand All @@ -298,8 +298,8 @@ namespace KinKal {
}

template <class KTRAJ> void PiecewiseTrajectory<KTRAJ>::pieceRange(TimeRange const& range,
std::deque<std::shared_ptr<KTRAJ>>::iterator& first,
std::deque<std::shared_ptr<KTRAJ>>::iterator& last) {
typename std::deque<std::shared_ptr<KTRAJ>>::iterator &first,
typename std::deque<std::shared_ptr<KTRAJ>>::iterator &last) {
first = last = pieces_.end();
// check for no overlap
if(this->range().overlaps(range)){
Expand Down
8 changes: 8 additions & 0 deletions cmake/KinKalConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/KinKalTargets.cmake")

include(CMakeFindDependencyMacro)
find_dependency(ROOT)

check_required_components(KinKal)