Skip to content

Commit

Permalink
use CyclusBuildSetup macros in cycamore build
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibbelink committed Sep 19, 2024
1 parent 4eb716e commit 2a10733
Showing 1 changed file with 17 additions and 63 deletions.
80 changes: 17 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
#taken from http://geant4.cern.ch/support/source/geant4/CMakeLists.txt
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Cycamore requires an out-of-source build.")
message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:")
message(STATUS "CMakeCache.txt")
message(STATUS "CMakeFiles")
message(STATUS "Once these files are removed, create a separate directory")
message(STATUS "and run CMake from there")
message(FATAL_ERROR "in-source build detected")
ENDIF()
SET(CYCAMORE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
# Tell CMake where the modules are
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_INSTALL_PREFIX}/share/cyclus/cmake")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CYCAMORE_SOURCE_DIR}/cmake)
MESSAGE("--CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}")

# Find cyclus
FIND_PACKAGE(Cyclus REQUIRED)
INCLUDE(CyclusBuildSetup)

cyclus_minimum_cmake_version(MINIMUM_CMAKE_VERSION)
CMAKE_MINIMUM_REQUIRED(VERSION ${MINIMUM_CMAKE_VERSION})

cyclus_require_out_of_source_build()

# This project name is cycamore.
PROJECT(CYCAMORE VERSION 1.6.0)

# check for and enable c++11 support (required for cyclus)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
IF(COMPILER_SUPPORTS_CXX17)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
ELSE()
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
ENDIF()
cyclus_require_cxx_support()

# quiets fortify_source warnings when not compiling with optimizations
# in linux distros where compilers were compiled with fortify_source enabled by
Expand All @@ -33,9 +29,6 @@ ENDIF()
# no overflow warnings because of silly coin-ness
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overflow")

# Direct any out-of-source builds to this directory
SET(CYCAMORE_SOURCE_DIR ${CMAKE_SOURCE_DIR})

IF(NOT CYCLUS_DOC_ONLY)
# Direct any binary installation paths to this directory
SET(CYCAMORE_BINARY_DIR ${CMAKE_BINARY_DIR})
Expand All @@ -44,48 +37,11 @@ IF(NOT CYCLUS_DOC_ONLY)
SET(BUILD_SHARED_LIBS true)

# Setup build locations.
IF(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CYCAMORE_BINARY_DIR}/bin)
endif()
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CYCAMORE_BINARY_DIR}/lib)
endif()
IF(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CYCAMORE_BINARY_DIR}/lib)
ENDIF()
cyclus_setup_build_locations(${CYCAMORE_BINARY_DIR})

SET(CYCAMORE_EXECUTABLE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/cyclus")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/cyclus")
GET_FILENAME_COMPONENT(cxxCompilerRoot ${CMAKE_CXX_COMPILER} DIRECTORY)
GET_FILENAME_COMPONENT(cxxCompilerRoot ${cxxCompilerRoot} DIRECTORY)
IF (NOT "${CMAKE_INSTALL_RPATH}" STREQUAL "${cxxCompilerRoot}")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${cxxCompilerRoot}/lib:${cxxCompilerRoot}/lib/cyclus")
ENDIF (NOT "${CMAKE_INSTALL_RPATH}" STREQUAL "${cxxCompilerRoot}")
SET(CMAKE_BUILD_RPATH "${CMAKE_INSTALL_RPATH}")
ENDIF("${isSystemDir}" STREQUAL "-1")
MESSAGE("-- CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}")

# Tell CMake where the modules are
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_INSTALL_PREFIX}/share/cyclus/cmake")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CYCAMORE_SOURCE_DIR}/cmake)
MESSAGE("--CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}")
cyclus_set_rpath()

# get dependency hints
if (NOT DEPS_ROOT_DIR)
Expand All @@ -105,8 +61,6 @@ IF(NOT CYCLUS_DOC_ONLY)
# Search pkg-config utility first
FIND_PACKAGE(PkgConfig REQUIRED)

# Find cyclus
FIND_PACKAGE(Cyclus REQUIRED)
SET(
CYCAMORE_INCLUDE_DIRS
${CYCAMORE_INCLUDE_DIRS}
Expand Down

0 comments on commit 2a10733

Please sign in to comment.