Skip to content

Commit

Permalink
Merge pull request #1002 from JJL772/apply-cmake-policies
Browse files Browse the repository at this point in the history
Fix CMake policy warnings
  • Loading branch information
ruck314 authored Jun 13, 2024
2 parents 860412f + bebe8da commit f2ce59d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 50 deletions.
35 changes: 18 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (DEFINED ENV{CONDA_PREFIX})
endif()

# Check cmake version
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
include(InstallRequiredSystemLibraries)

# Set default release type
Expand All @@ -45,8 +45,9 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# Boost + Python
#####################################
if ( NOT NO_PYTHON )
find_package(PythonInterp 3 QUIET REQUIRED)
find_package(PythonLibs 3 QUIET REQUIRED)
# Find newest python interpreter first
set(Python3_FIND_STRATEGY "VERSION")
find_package(Python3 QUIET REQUIRED COMPONENTS Interpreter Development)

# Find Numpy
execute_process(
Expand All @@ -66,21 +67,21 @@ if ( NOT NO_PYTHON )

# Hint for boost on anaconda
if (DEFINED ENV{CONDA_PREFIX})
set(BOOST_ROOT $ENV{CONDA_PREFIX})
set(Boost_ROOT $ENV{CONDA_PREFIX})

# SLAC AFS custom path
elseif (DEFINED ENV{BOOST_PATH})
set(BOOST_ROOT $ENV{BOOST_PATH})
set(Boost_ROOT $ENV{BOOST_PATH})
endif()

# libboost_python3.7 style libraries
message("Looking for libboost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})

# libboost_python3 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python${PYTHON_VERSION_MAJOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR})
message("Looking for libboost_python${Python3_VERSION_MAJOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR})
endif()

# libboost_python style libraries
Expand All @@ -91,14 +92,14 @@ if ( NOT NO_PYTHON )

# libboost_python-py37 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
endif()

# libboost_python3-py37 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
endif()

# Nothing worked
Expand Down Expand Up @@ -233,7 +234,7 @@ configure_file (
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR})
include_directories(system ${Boost_INCLUDE_DIRS})
include_directories(system ${PYTHON_INCLUDE_DIRS})
include_directories(system ${Python3_INCLUDE_DIRS})
include_directories(system ${Python3_NumPy_INCLUDE_DIRS})
include_directories(system ${ZeroMQ_INCLUDE_DIR})
include_directories(system ${BZIP2_INCLUDE_DIR})
Expand Down Expand Up @@ -267,7 +268,7 @@ TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${BZIP2_LIBRARIES})
if (APPLE)
set_target_properties(rogue-core-shared PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${Python3_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC rt)
endif()

Expand All @@ -281,7 +282,7 @@ if(STATIC_LIB)
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${ZeroMQ_LIBRARY})
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${EPICS_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${BZIP2_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${Python3_LIBRARIES})
TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC rt)
endif()

Expand Down Expand Up @@ -417,7 +418,7 @@ else()
message("-- Found boost: ${Boost_INCLUDE_DIRS}")
message("-- Found boost: ${Boost_LIBRARIES}")
message("")
message("-- Found python: ${PYTHON_LIBRARIES}")
message("-- Found python: ${Python3_LIBRARIES}")
message("-- Found numpy: ${Python3_NumPy_INCLUDE_DIRS}")
endif()

Expand Down
36 changes: 20 additions & 16 deletions buildroot-2019.08-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER_AR /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ar)
set(CMAKE_ASM_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc)
set(CMAKE_C_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc)
set(CMAKE_CXX_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-g++)
set(CMAKE_LINKER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ld)
set(CMAKE_OBJCOPY /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-objcopy)
set(CMAKE_C_COMPILER_RANLIB /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ranlib)
set(CMAKE_SIZE /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-size)
set(CMAKE_STRIP /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-strip)
if (NOT DEFINED BUILDROOT_TOP)
set(BUILDROOT_TOP "/sdf/sw/epics/package/linuxRT/buildroot-2019.08")
endif()

set(CMAKE_C_COMPILER_AR "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ar")
set(CMAKE_ASM_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc")
set(CMAKE_C_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc")
set(CMAKE_CXX_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-g++")
set(CMAKE_LINKER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ld")
set(CMAKE_OBJCOPY "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-objcopy")
set(CMAKE_C_COMPILER_RANLIB "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ranlib")
set(CMAKE_SIZE "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-size")
set(CMAKE_STRIP "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-strip")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Define location of BZIP2 (cross-compiled)
set(BZIP2_LIBRARIES /afs/slac/g/lcls/package/bzip2/1.0.6/buildroot-2019.08-x86_64/lib/libbz2.a)
set(BZIP2_INCLUDE_DIR /afs/slac/g/lcls/package/bzip2/1.0.6/buildroot-2019.08-x86_64/include)
set(BZIP2_LIBRARIES "$ENV{PACKAGE_TOP}/bzip2/1.0.6/buildroot-2019.08-x86_64/lib/libbz2.a")
set(BZIP2_INCLUDE_DIR "$ENV{PACKAGE_TOP}/bzip2/1.0.6/buildroot-2019.08-x86_64/include")

# Define the location of ZMQ (cross-compiled)
set(ZeroMQ_LIBRARY /afs/slac/g/lcls/package/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/lib/libzmq.a)
set(ZeroMQ_INCLUDE_DIR /afs/slac/g/lcls/package/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/include)
set(ZeroMQ_LIBRARY "$ENV{PACKAGE_TOP}/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/lib/libzmq.a")
set(ZeroMQ_INCLUDE_DIR "$ENV{PACKAGE_TOP}/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/include")

# Define the location of python3 (cross-compiled)
set(PYTHON_LIBRARY /afs/slac/g/lcls/package/python/3.6.1/buildroot-2019.08-x86_64/lib/libpython3.6m.so)
set(PYTHON_INCLUDE_DIR /afs/slac/g/lcls/package/python/3.6.1/buildroot-2019.08-x86_64/include/python3.6m)
set(Python3_LIBRARY "$ENV{PACKAGE_TOP}/python/3.6.1/buildroot-2019.08-x86_64/lib/libpython3.6m.so")
set(Python3_INCLUDE_DIR "$ENV{PACKAGE_TOP}/python/3.6.1/buildroot-2019.08-x86_64/include/python3.6m")

# Define the location of boost (cross-compiled)
set(BOOST_ROOT /afs/slac/g/lcls/package/boost/1.64.0/buildroot-2019.08-x86_64)
set(BOOST_ROOT "$ENV{PACKAGE_TOP}/boost/1.64.0/buildroot-2019.08-x86_64")
35 changes: 18 additions & 17 deletions templates/RogueConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ set(NO_PYTHON @NO_PYTHON@)
# Boost + Python
#####################################
if ( NOT NO_PYTHON )
find_package(PythonInterp 3 QUIET REQUIRED)
find_package(PythonLibs 3 QUIET REQUIRED)
# Search for newest version of Python3 first
set(Python3_FIND_STRATEGY "VERSION")
find_package(Python3 QUIET REQUIRED COMPONENTS Interpreter Development)

# Find Numpy
execute_process(
Expand All @@ -47,21 +48,21 @@ if ( NOT NO_PYTHON )

# Hint for boost on anaconda
if (DEFINED ENV{CONDA_PREFIX})
set(BOOST_ROOT $ENV{CONDA_PREFIX})
set(Boost_ROOT $ENV{CONDA_PREFIX})

# SLAC AFS custom path
elseif (DEFINED ENV{BOOST_PATH})
set(BOOST_ROOT $ENV{BOOST_PATH})
set(Boost_ROOT $ENV{BOOST_PATH})
endif()

# libboost_python3.7 style libraries
message("Looking for libboost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})

# libboost_python3 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python${PYTHON_VERSION_MAJOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR})
message("Looking for libboost_python${Python3_VERSION_MAJOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR})
endif()

# libboost_python style libraries
Expand All @@ -72,14 +73,14 @@ if ( NOT NO_PYTHON )

# libboost_python-py37 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
endif()

# libboost_python3-py37 style libraries
if (NOT Boost_FOUND)
message("Looking for libboost_python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
message("Looking for libboost_python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
endif()

# Nothing worked
Expand Down Expand Up @@ -145,8 +146,8 @@ endif()
# These variables are now defined
# ${Boost_INCLUDE_DIRS}
# ${Boost_LIBRARIES}
# ${PYTHON_INCLUDE_DIRS}
# ${PYTHON_LIBRARIES}
# ${Python3_INCLUDE_DIRS}
# ${Python3_LIBRARIES}
# ${ZeroMQ_INCLUDE_DIR}
# ${ZeroMQ_LIBRARY}
# ${BZIP2_INCLUDE_DIR}
Expand All @@ -163,7 +164,7 @@ set(ROGUE_LIBRARIES_ONLY @CONF_LIBRARIES@)
# Rogue Include paths
set(ROGUE_INCLUDE_DIRS @CONF_INCLUDE_DIRS@
${Boost_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${Python3_INCLUDE_DIRS}
${Python3_NumPy_INCLUDE_DIRS}
${ZeroMQ_INCLUDE_DIR}
${BZIP2_INCLUDE_DIR}
Expand All @@ -172,7 +173,7 @@ set(ROGUE_INCLUDE_DIRS @CONF_INCLUDE_DIRS@
# Rogue libraries
set(ROGUE_LIBRARIES @CONF_LIBRARIES@
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
${Python3_LIBRARIES}
${ZeroMQ_LIBRARY}
${BZIP2_LIBRARIES}
${EPICS_LIBRARIES})
Expand Down Expand Up @@ -200,7 +201,7 @@ else()
message("-- Found boost: ${Boost_INCLUDE_DIRS}")
message("-- Found boost: ${Boost_LIBRARIES}")
message("")
message("-- Found python: ${PYTHON_LIBRARIES}")
message("-- Found python: ${Python3_LIBRARIES}")
message("-- Found numpy: ${Python3_NumPy_INCLUDE_DIRS}")
endif()

Expand Down

0 comments on commit f2ce59d

Please sign in to comment.