Skip to content
Snippets Groups Projects
Commit 465bf0a7 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

feat : homogeinized cmakelists with backend_cpu

parent 22915341
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!116feat/release_pip
Pipeline #45872 canceled
############################################################################### ###############################################################################
# Aidge Continuous Integration and Continious Deployment # # Aidge Continuous Integration and Deployment #
# # # #
############################################################################### ###############################################################################
...@@ -18,5 +18,4 @@ include: ...@@ -18,5 +18,4 @@ include:
- '.gitlab/ci/ubuntu_cpp.gitlab-ci.yml' - '.gitlab/ci/ubuntu_cpp.gitlab-ci.yml'
- '.gitlab/ci/ubuntu_python.gitlab-ci.yml' - '.gitlab/ci/ubuntu_python.gitlab-ci.yml'
- '.gitlab/ci/windows_cpp.gitlab-ci.yml' - '.gitlab/ci/windows_cpp.gitlab-ci.yml'
- '.gitlab/ci/windows_python.gitlab-ci.yml' - '.gitlab/ci/windows_python.gitlab-ci.yml'
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
message(STATUS "Project name: ${project}") project(aidge_core
VERSION ${version}
DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework"
LANGUAGES CXX)
message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}")
add_definitions(-DPROJECT_VERSION="${version}")
message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}") message(STATUS "Project version: ${version}")
# Note : project name is {project} and python module name is also {project} # Note : project name is {project} and python module name is also {project}
set(module_name _${project}) # target name # set(module_name _${CMAKE_PROJECT_NAME}) # target name
project(${project})
set(CXX_STANDARD 14) set(CXX_STANDARD 14)
############################################## ##############################################
...@@ -80,9 +86,15 @@ endif() ...@@ -80,9 +86,15 @@ endif()
# PYTHON BINDING # PYTHON BINDING
if (PYBIND) if (PYBIND)
include(PybindModuleCreation) # Handles Python + pybind11 headers dependencies
# retrieves pybind and python pkg and link them to _aidge_core generate_python_binding(${CMAKE_PROJECT_NAME} ${module_name})
generate_python_binding()
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Module
)
endif() endif()
target_link_libraries(${module_name} PUBLIC Threads::Threads fmt::fmt) target_link_libraries(${module_name} PUBLIC Threads::Threads fmt::fmt)
...@@ -135,9 +147,9 @@ if(NOT $ENV{AIDGE_INSTALL} STREQUAL "") ...@@ -135,9 +147,9 @@ if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
endif() endif()
include(GNUInstallDirs) include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${project}) # set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
install(TARGETS ${module_name} EXPORT ${project}-targets # install(TARGETS ${module_name} EXPORT ${CMAKE_PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
...@@ -148,8 +160,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ...@@ -148,8 +160,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#Export the targets to a script #Export the targets to a script
install(EXPORT ${project}-targets # install(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${project}-targets.cmake" # FILE "${CMAKE_PROJECT_NAME}-targets.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
# COMPONENT ${module_name} # COMPONENT ${module_name}
) )
...@@ -158,28 +170,28 @@ install(EXPORT ${project}-targets ...@@ -158,28 +170,28 @@ install(EXPORT ${project}-targets
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" # "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
VERSION ${version} VERSION ${version}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
configure_package_config_file("${project}-config.cmake.in" # configure_package_config_file("${CMAKE_PROJECT_NAME}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" # "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR} INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
) )
#Install the config, configversion and custom find modules #Install the config, configversion and custom find modules
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" # "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" # "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
) )
############################################## ##############################################
## Exporting from the build tree ## Exporting from the build tree
message(STATUS "Exporting created targets to use them in another build") message(STATUS "Exporting created targets to use them in another build")
export(EXPORT ${project}-targets # export(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-targets.cmake") # FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake")
############################################## ##############################################
......
macro(generate_python_binding ) function(generate_python_binding pybind_module_name target_to_bind)
add_definitions(-DPYBIND) add_definitions(-DPYBIND)
Include(FetchContent) Include(FetchContent)
# Use the New FindPython mode, recommanded. Requires CMake 3.15+
find_package(Python 3.7.0
COMPONENTS Interpreter Development.Module
REQUIRED)
set(PYBIND11_FINDPYTHON ON)
set(PYBIND_VERSION v2.10.4) set(PYBIND_VERSION v2.10.4)
set(PYBIND11_FINDPYTHON ON)
message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git") message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git")
FetchContent_Declare( FetchContent_Declare(
PyBind11 PyBind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG ${PYBIND_VERSION} # or a later release GIT_TAG ${PYBIND_VERSION} # or a later release
) )
# Use the New FindPython mode, recommanded. Requires CMake 3.15+
find_package(Python COMPONENTS Interpreter Development.Module)
FetchContent_MakeAvailable(PyBind11) FetchContent_MakeAvailable(PyBind11)
message(STATUS "Creating binding for module ${project}") message(STATUS "Creating binding for module ${pybind_module_name}")
file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp")
pybind11_add_module(${project} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA required for pip install pybind11_add_module(${pybind_module_name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install
target_include_directories(${project} PUBLIC "python_binding" ${pybind11_INCLUDE_DIRECTORIES}) target_include_directories(${pybind_module_name} PUBLIC "python_binding")
# Handles Python + pybind11 headers dependencies target_link_libraries(${pybind_module_name} PUBLIC ${target_to_bind})
target_link_libraries(${module_name} endfunction()
PRIVATE
Python::Module
PUBLIC
pybind11::pybind11
)
target_link_libraries(${project} PUBLIC ${module_name})
endmacro()
[project] [project]
name = "aidge_core" name = "aidge_core"
description="Core alogrithms for operators and graph of the AIDGE framework" description="Core algorithms for operators and graph of the AIDGE framework"
dependencies = [ dependencies = [
"numpy>=1.21.6", "numpy>=1.21.6",
"Jinja2>=3.1.2" "Jinja2>=3.1.2"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment