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

Commit

Permalink
Merge pull request #8 from kreczko/cmake-and-restructure
Browse files Browse the repository at this point in the history
Cmake and restructure
  • Loading branch information
kreczko committed Feb 16, 2015
2 parents ec05705 + 1d7ed25 commit 5e00dbe
Show file tree
Hide file tree
Showing 36 changed files with 865 additions and 1,355 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
libRooUnfold.so
tmp
/Release/
Debug
Release
.cp*
.py*
.project
CMakeFiles
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
rootdict
RooUnfold_test
Makefile
*~
*Dict.cxx
*Dict_rdict.pcm
Test*
85 changes: 85 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Check if cmake has the required version
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)

set(PROJECT_NAME_STR RooUnfold)
set(PROJECT_LIB_NAME ${PROJECT_NAME_STR})
PROJECT(${PROJECT_NAME_STR})
include_directories(include)

set(CINTFILE ${PROJECT_NAME_STR}Dict.cxx)
file(GLOB LINK_DEF_FILE include/*_LinkDef.h)
file(GLOB HEADER_FILES include/*.h)
list(REMOVE_ITEM HEADER_FILES ${LINK_DEF_FILE})


if((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (CMAKE_SIZEOF_VOID_P EQUAL 8) AND (APPLE))
set(CMAKE_OSX_ARCHITECTURES "x86_64")
MESSAGE(STATUS "Building ${PROJECT_NAME_STR} for ${CMAKE_OSX_ARCHITECTURES} architecture on ${CMAKE_SYSTEM_NAME}")
else()
MESSAGE(STATUS "Building ${PROJECT_NAME_STR} on ${CMAKE_SYSTEM_NAME}")
endif()
MESSAGE(STATUS "Using compiler ${CMAKE_CXX_COMPILER_ID}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
MESSAGE(STATUS "Using CMAKE module path ${CMAKE_SOURCE_DIR}")

# get ROOT
find_package(ROOT "5.34" REQUIRED)
MESSAGE(STATUS "** ROOT Include path: ${ROOT_INCLUDE_DIRS}")
MESSAGE(STATUS "** ROOT Library path: ${ROOT_LIBRARY_DIRS}")
MESSAGE(STATUS "** ROOT Libraries: ${ROOT_LIBRARIES}")

include_directories(${ROOT_INCLUDE_DIRS})
link_directories(${ROOT_LIBRARY_DIRS})

# load helper macros for using rootcint
INCLUDE( ${ROOT_DICT_MACROS_FILE} )
set(ROOT_DICT_INPUT_HEADERS ${HEADER_FILES})
set(ROOT_DICT_OUTPUT_DIR ${PROJECT_SOURCE_DIR})
# and add LinkDef file to the end
LIST( APPEND ROOT_DICT_INPUT_HEADERS ${LINK_DEF_FILE} )

# generate dictionary sources using rootcint
GEN_ROOT_DICT_SOURCE( ${CINTFILE} )

# get boost
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS
unit_test_framework
REQUIRED)
MESSAGE(STATUS "** Boost Include path: ${Boost_INCLUDE_DIR}")
MESSAGE(STATUS "** Boost Library path: ${Boost_LIBRARY_DIRS}")
MESSAGE(STATUS "** Boost Libraries: ${Boost_LIBRARIES}")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

#Check the compiler and set the compile and link flags
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11")
# first attempt to make cmake work again on OS X
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (APPLE))
MESSAGE(STATUS "** std library for clang: libc++")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -stdlib=libc++")
endif()

# adding the library
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
LIST(APPEND SRC ${ROOT_DICT_OUTPUT_SOURCES} )
add_library(${PROJECT_LIB_NAME} SHARED ${SRC})
target_link_libraries(${PROJECT_LIB_NAME}
${Boost_LIBRARIES}
${ROOT_LIBRARIES}
)

# tests
enable_testing()
set(PROJECT_TEST_NAME ${PROJECT_NAME_STR}_test)
include_directories(${COMMON_INCLUDES})
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp)
add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
target_link_libraries(${PROJECT_TEST_NAME}
${Boost_LIBRARIES}
${ROOT_LIBRARIES}
${PROJECT_LIB_NAME}
)

add_test(test1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_TEST_NAME})
Loading

0 comments on commit 5e00dbe

Please sign in to comment.