diff --git a/CMakeLists.txt b/CMakeLists.txt index aa994252..68a09586 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,26 +11,40 @@ project( # Include CTest to provide BUILD_TESTING option include(CTest) +include(FetchContent) +include(GNUInstallDirs) + +# Declare build options +#option(XMIPP4_BINDING_PYTHON_BUILD_DOC "Build documentation" ON) + +# Set the module path +#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) + +# Find Python +find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) + +# Obtain pybind11 +FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11 + GIT_TAG v2.12.0 +) +FetchContent_MakeAvailable(pybind11) # Find xmipp4-core if (NOT TARGET xmipp4-core) find_package(xmipp4-core REQUIRED) endif() -# Find Python -find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) - if(SKBUILD_PLATLIB_DIR) set(PYTHON_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}") else() set(PYTHON_INSTALL_DIR "${Python_SITEARCH}") endif() -# Declare build options -#option(XMIPP4_BINDING_PYTHON_BUILD_DOC "Build documentation" ON) - -# Set the module path -#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) +# Set project-wide compilation options +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED OFF) # Add sources add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79412b2b..c9ce382d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,16 +1,5 @@ cmake_minimum_required(VERSION 3.16) -include(FetchContent) -include(GNUInstallDirs) - -# Obtain pybind11 -FetchContent_Declare( - pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG v2.12.0 -) -FetchContent_MakeAvailable(pybind11) - # Register all source and header files file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.c) file(GLOB_RECURSE HEADERS ${PROJECT_SOURCE_DIR}/include/*.h ${PROJECT_SOURCE_DIR}/include/*.hpp) @@ -19,11 +8,6 @@ file(GLOB_RECURSE INLINE_SOURCES ${PROJECT_SOURCE_DIR}/include/*.inl) # Create the shared library set(TARGET_NAME "_core_binding") pybind11_add_module(${TARGET_NAME} ${SOURCES}) -set_target_properties( - ${TARGET_NAME} - PROPERTIES - CXX_STANDARD 20 -) target_compile_definitions( ${TARGET_NAME} PRIVATE @@ -31,13 +15,10 @@ target_compile_definitions( VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR} VERSION_PATCH=${CMAKE_PROJECT_VERSION_PATCH} ) -target_precompile_headers( - ${TARGET_NAME} - PRIVATE ${HEADERS} -) target_link_libraries( ${TARGET_NAME} - PRIVATE xmipp4-core + PRIVATE + xmipp4-core ) if(MSVC) target_compile_options(${TARGET_NAME} PRIVATE /W4 /WX)