From 0a07bacf5da436c1c604a06d298b8c0b71386451 Mon Sep 17 00:00:00 2001 From: davidmcdonagh Date: Wed, 13 Dec 2023 10:15:32 +0000 Subject: [PATCH] Changes to allow for CMake build. --- .conda-envs/linux.txt | 2 +- .conda-envs/macos.txt | 2 +- .conda-envs/windows.txt | 2 +- .pre-commit-config.yaml | 2 +- CMakeLists.txt | 14 ++++++++++---- cmake/Modules/AlwaysColourCompilation.cmake | 2 +- cmake/Modules/FindCCTBX.cmake | 2 +- src/dials/array_family/CMakeLists.txt | 4 ++-- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.conda-envs/linux.txt b/.conda-envs/linux.txt index 46522d9c2f..2f0cc7a144 100644 --- a/.conda-envs/linux.txt +++ b/.conda-envs/linux.txt @@ -20,7 +20,7 @@ conda-forge::jinja2 conda-forge::jpeg conda-forge::matplotlib-base>=3.0.2 conda-forge::mrcfile -conda-forge::msgpack-c +conda-forge::msgpack-cxx conda-forge::msgpack-python conda-forge::numpy>=1.19,<1.21|>=1.21.5 conda-forge::orderedset diff --git a/.conda-envs/macos.txt b/.conda-envs/macos.txt index ec726368c0..8497f020cf 100644 --- a/.conda-envs/macos.txt +++ b/.conda-envs/macos.txt @@ -21,7 +21,7 @@ conda-forge::jpeg conda-forge::libcxx conda-forge::matplotlib-base>=3.0.2 conda-forge::mrcfile -conda-forge::msgpack-c +conda-forge::msgpack-cxx conda-forge::msgpack-python conda-forge::numpy>=1.19,<1.21|>=1.21.5 conda-forge::orderedset diff --git a/.conda-envs/windows.txt b/.conda-envs/windows.txt index 46522d9c2f..2f0cc7a144 100644 --- a/.conda-envs/windows.txt +++ b/.conda-envs/windows.txt @@ -20,7 +20,7 @@ conda-forge::jinja2 conda-forge::jpeg conda-forge::matplotlib-base>=3.0.2 conda-forge::mrcfile -conda-forge::msgpack-c +conda-forge::msgpack-cxx conda-forge::msgpack-python conda-forge::numpy>=1.19,<1.21|>=1.21.5 conda-forge::orderedset diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6559171904..a4e0a07838 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: # Automatically sort imports - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: [ diff --git a/CMakeLists.txt b/CMakeLists.txt index fd684262b5..7429bb099e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,13 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) project(dials) # Add the included modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") # General cmake environment configuration include(SetDefaultBuildRelWithDebInfo) # Default builds to release with debug info include(CoverageBuildConfiguration) # Custom module to make turning coverage on easy include(AlwaysColourCompilation) # Always show coloured compiler output +include(CheckCXXSymbolExists) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json set(CMAKE_CXX_STANDARD 14) @@ -16,8 +17,14 @@ set(CMAKE_CXX_STANDARD 14) find_package(Python REQUIRED COMPONENTS Interpreter Development) find_package(CCTBX COMPONENTS cctbx scitbx ccp4io annlib REQUIRED) find_package(DXTBX REQUIRED) -find_package(msgpack REQUIRED) find_package(OpenMP) +# Handle msgpack.. between versions 3 and 6, split into separate packages. +# While we still support both, look for both names +find_package(msgpack-cxx REQUIRED NAMES msgpack-cxx msgpack) +if (TARGET msgpackc AND NOT TARGET msgpack-cxx) + # If the old version of the library, let us refer to the new name + add_library(msgpack-cxx ALIAS msgpackc) +endif() # Find the boost::python library for this version of python set(Boost_USE_STATIC_LIBS OFF) # This is the default everywhere except Windows @@ -26,8 +33,7 @@ find_package(Boost COMPONENTS thread "python${Python_VERSION_MAJOR}${Python_VERS # Create Boost::python alias so we don't need to carry the python version around if(NOT TARGET Boost::python) add_library(Boost::python INTERFACE IMPORTED) - set_target_properties(Boost::python PROPERTIES - INTERFACE_LINK_LIBRARIES "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}" ) + set_target_properties(Boost::python PROPERTIES INTERFACE_LINK_LIBRARIES Python::Module) endif() # Put the libraries into lib/ so that we can run this in-place in a TBX install diff --git a/cmake/Modules/AlwaysColourCompilation.cmake b/cmake/Modules/AlwaysColourCompilation.cmake index 9e2f3f7ebc..6a4d66c65f 100644 --- a/cmake/Modules/AlwaysColourCompilation.cmake +++ b/cmake/Modules/AlwaysColourCompilation.cmake @@ -1,7 +1,7 @@ # Add compiler flags to always output coloured diagnostics # # This is an issue with Ninja where it captures the output to avoid -# intermixing output like the makefile generator. Unfortuantely, +# intermixing output like the makefile generator. Unfortunately, # the compiler detects it's being captured and doesn't output the # coloured diagnostics. # diff --git a/cmake/Modules/FindCCTBX.cmake b/cmake/Modules/FindCCTBX.cmake index 40f5bbf7b2..ded2129dae 100644 --- a/cmake/Modules/FindCCTBX.cmake +++ b/cmake/Modules/FindCCTBX.cmake @@ -188,7 +188,7 @@ function(_cctbx_read_module MODULE) endif() endforeach() else() - # We didn't have any speciic override. If include/ exists + # We didn't have any specific override. If include/ exists # then use that, otherwise use the module parent directory. if (EXISTS "${_dist_path}/include") list(APPEND _include_paths "${_dist_path}/include") diff --git a/src/dials/array_family/CMakeLists.txt b/src/dials/array_family/CMakeLists.txt index cd8279993e..c1f93454b6 100644 --- a/src/dials/array_family/CMakeLists.txt +++ b/src/dials/array_family/CMakeLists.txt @@ -18,5 +18,5 @@ target_link_libraries( CCTBX::cctbx Boost::python CCTBX::scitbx::boost_python - msgpackc -) \ No newline at end of file + msgpack-cxx +)