Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 2 additions & 21 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -19,25 +8,17 @@ 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
VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}
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)
Expand Down
Loading