diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee8187cd431b3e48e4b5f34dfbcd86ae59ed917b..e5eff3fbbfaeddd6281254da19750ff1dc9638f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ ############################################################################### -# Aidge Continuous Integration and Continious Deployment # +# Aidge Continuous Integration and Deployment # # # ############################################################################### @@ -18,5 +18,4 @@ include: - '.gitlab/ci/ubuntu_cpp.gitlab-ci.yml' - '.gitlab/ci/ubuntu_python.gitlab-ci.yml' - '.gitlab/ci/windows_cpp.gitlab-ci.yml' - - '.gitlab/ci/windows_python.gitlab-ci.yml' - + - '.gitlab/ci/windows_python.gitlab-ci.yml' diff --git a/CMakeLists.txt b/CMakeLists.txt index efbb6372a31ea7e610e13978ce1cb84d5084acc9..c2c1d1a132ee46920b2b595d01b73042cf27421f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,22 @@ cmake_minimum_required(VERSION 3.15) -file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) -file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) +file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version) -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}") # 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) ############################################## @@ -80,9 +86,15 @@ endif() # PYTHON BINDING if (PYBIND) - include(PybindModuleCreation) - # retrieves pybind and python pkg and link them to _aidge_core - generate_python_binding() + # Handles Python + pybind11 headers dependencies + generate_python_binding(${CMAKE_PROJECT_NAME} ${module_name}) + + target_link_libraries(${module_name} + PUBLIC + pybind11::pybind11 + PRIVATE + Python::Module + ) endif() target_link_libraries(${module_name} PUBLIC Threads::Threads fmt::fmt) @@ -135,9 +147,9 @@ if(NOT $ENV{AIDGE_INSTALL} STREQUAL "") endif() 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} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -148,8 +160,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) #Export the targets to a script -install(EXPORT ${project}-targets - FILE "${project}-targets.cmake" +# install(EXPORT ${CMAKE_PROJECT_NAME}-targets +# FILE "${CMAKE_PROJECT_NAME}-targets.cmake" DESTINATION ${INSTALL_CONFIGDIR} # COMPONENT ${module_name} ) @@ -158,28 +170,28 @@ install(EXPORT ${project}-targets include(CMakePackageConfigHelpers) 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} COMPATIBILITY AnyNewerVersion ) -configure_package_config_file("${project}-config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" +# configure_package_config_file("${CMAKE_PROJECT_NAME}-config.cmake.in" +# "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake" INSTALL_DESTINATION ${INSTALL_CONFIGDIR} ) #Install the config, configversion and custom find modules install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" +# "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake" +# "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake" DESTINATION ${INSTALL_CONFIGDIR} ) ############################################## ## Exporting from the build tree message(STATUS "Exporting created targets to use them in another build") -export(EXPORT ${project}-targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-targets.cmake") +# export(EXPORT ${CMAKE_PROJECT_NAME}-targets +# FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake") ############################################## diff --git a/cmake/PybindModuleCreation.cmake b/cmake/PybindModuleCreation.cmake index 32f67e0d969b39197b45392a2e013710c58e2171..8f386bef59ed86dfa366eca5d4fccae24b28d24e 100644 --- a/cmake/PybindModuleCreation.cmake +++ b/cmake/PybindModuleCreation.cmake @@ -1,32 +1,25 @@ -macro(generate_python_binding ) +function(generate_python_binding pybind_module_name target_to_bind) add_definitions(-DPYBIND) 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(PYBIND11_FINDPYTHON ON) message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git") + FetchContent_Declare( - PyBind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG ${PYBIND_VERSION} # or a later release + PyBind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + 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) - - 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") - pybind11_add_module(${project} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA required for pip install - target_include_directories(${project} PUBLIC "python_binding" ${pybind11_INCLUDE_DIRECTORIES}) - # Handles Python + pybind11 headers dependencies - target_link_libraries(${module_name} - PRIVATE - Python::Module - PUBLIC - pybind11::pybind11 - ) - target_link_libraries(${project} PUBLIC ${module_name}) -endmacro() + pybind11_add_module(${pybind_module_name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install + target_include_directories(${pybind_module_name} PUBLIC "python_binding") + target_link_libraries(${pybind_module_name} PUBLIC ${target_to_bind}) +endfunction() diff --git a/pyproject.toml b/pyproject.toml index 2c4b8b2afe448f39c9967da6eb1e3b13eb293489..6083074b3c6e39e191b6380d568159be09cb682b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] 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 = [ "numpy>=1.21.6", "Jinja2>=3.1.2"