Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit 5e00dbe

Browse files
committed
Merge pull request #8 from kreczko/cmake-and-restructure
Cmake and restructure
2 parents ec05705 + 1d7ed25 commit 5e00dbe

36 files changed

+865
-1355
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
libRooUnfold.so
22
tmp
3+
/Release/
4+
Debug
5+
Release
6+
.cp*
7+
.py*
8+
.project
9+
CMakeFiles
10+
CMakeCache.txt
11+
cmake_install.cmake
12+
CTestTestfile.cmake
13+
rootdict
14+
RooUnfold_test
15+
Makefile
16+
*~
17+
*Dict.cxx
18+
*Dict_rdict.pcm
19+
Test*

CMakeLists.txt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Check if cmake has the required version
2+
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
3+
4+
set(PROJECT_NAME_STR RooUnfold)
5+
set(PROJECT_LIB_NAME ${PROJECT_NAME_STR})
6+
PROJECT(${PROJECT_NAME_STR})
7+
include_directories(include)
8+
9+
set(CINTFILE ${PROJECT_NAME_STR}Dict.cxx)
10+
file(GLOB LINK_DEF_FILE include/*_LinkDef.h)
11+
file(GLOB HEADER_FILES include/*.h)
12+
list(REMOVE_ITEM HEADER_FILES ${LINK_DEF_FILE})
13+
14+
15+
if((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (CMAKE_SIZEOF_VOID_P EQUAL 8) AND (APPLE))
16+
set(CMAKE_OSX_ARCHITECTURES "x86_64")
17+
MESSAGE(STATUS "Building ${PROJECT_NAME_STR} for ${CMAKE_OSX_ARCHITECTURES} architecture on ${CMAKE_SYSTEM_NAME}")
18+
else()
19+
MESSAGE(STATUS "Building ${PROJECT_NAME_STR} on ${CMAKE_SYSTEM_NAME}")
20+
endif()
21+
MESSAGE(STATUS "Using compiler ${CMAKE_CXX_COMPILER_ID}")
22+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
23+
MESSAGE(STATUS "Using CMAKE module path ${CMAKE_SOURCE_DIR}")
24+
25+
# get ROOT
26+
find_package(ROOT "5.34" REQUIRED)
27+
MESSAGE(STATUS "** ROOT Include path: ${ROOT_INCLUDE_DIRS}")
28+
MESSAGE(STATUS "** ROOT Library path: ${ROOT_LIBRARY_DIRS}")
29+
MESSAGE(STATUS "** ROOT Libraries: ${ROOT_LIBRARIES}")
30+
31+
include_directories(${ROOT_INCLUDE_DIRS})
32+
link_directories(${ROOT_LIBRARY_DIRS})
33+
34+
# load helper macros for using rootcint
35+
INCLUDE( ${ROOT_DICT_MACROS_FILE} )
36+
set(ROOT_DICT_INPUT_HEADERS ${HEADER_FILES})
37+
set(ROOT_DICT_OUTPUT_DIR ${PROJECT_SOURCE_DIR})
38+
# and add LinkDef file to the end
39+
LIST( APPEND ROOT_DICT_INPUT_HEADERS ${LINK_DEF_FILE} )
40+
41+
# generate dictionary sources using rootcint
42+
GEN_ROOT_DICT_SOURCE( ${CINTFILE} )
43+
44+
# get boost
45+
set(Boost_USE_MULTITHREADED ON)
46+
find_package(Boost COMPONENTS
47+
unit_test_framework
48+
REQUIRED)
49+
MESSAGE(STATUS "** Boost Include path: ${Boost_INCLUDE_DIR}")
50+
MESSAGE(STATUS "** Boost Library path: ${Boost_LIBRARY_DIRS}")
51+
MESSAGE(STATUS "** Boost Libraries: ${Boost_LIBRARIES}")
52+
include_directories(${Boost_INCLUDE_DIRS})
53+
link_directories(${Boost_LIBRARY_DIRS})
54+
55+
#Check the compiler and set the compile and link flags
56+
set(CMAKE_BUILD_TYPE Release)
57+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11")
58+
# first attempt to make cmake work again on OS X
59+
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (APPLE))
60+
MESSAGE(STATUS "** std library for clang: libc++")
61+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -stdlib=libc++")
62+
endif()
63+
64+
# adding the library
65+
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
66+
LIST(APPEND SRC ${ROOT_DICT_OUTPUT_SOURCES} )
67+
add_library(${PROJECT_LIB_NAME} SHARED ${SRC})
68+
target_link_libraries(${PROJECT_LIB_NAME}
69+
${Boost_LIBRARIES}
70+
${ROOT_LIBRARIES}
71+
)
72+
73+
# tests
74+
enable_testing()
75+
set(PROJECT_TEST_NAME ${PROJECT_NAME_STR}_test)
76+
include_directories(${COMMON_INCLUDES})
77+
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp)
78+
add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
79+
target_link_libraries(${PROJECT_TEST_NAME}
80+
${Boost_LIBRARIES}
81+
${ROOT_LIBRARIES}
82+
${PROJECT_LIB_NAME}
83+
)
84+
85+
add_test(test1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_TEST_NAME})

0 commit comments

Comments
 (0)