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

Merge branch 'users/cguillon/dev-build-test' into 'dev'

[Build] Align build to new aidge_core dependencies

See merge request !89
parents 290e8042 1bcf11d8
No related branches found
No related tags found
2 merge requests!93Release v0.3.0,!89[Build] Align build to new aidge_core dependencies
Pipeline #55116 failed
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.18)
set(CXX_STANDARD 14) set(CXX_STANDARD 14)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version) file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
...@@ -76,13 +76,6 @@ if (PYBIND) ...@@ -76,13 +76,6 @@ if (PYBIND)
include(PybindModuleCreation) include(PybindModuleCreation)
generate_python_binding(${pybind_module_name} ${module_name}) generate_python_binding(${pybind_module_name} ${module_name})
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Module
)
endif() endif()
if( ${ENABLE_ASAN} ) if( ${ENABLE_ASAN} )
...@@ -106,7 +99,6 @@ target_include_directories(${module_name} ...@@ -106,7 +99,6 @@ target_include_directories(${module_name}
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src
) )
target_link_libraries(${module_name} PUBLIC fmt::fmt)
target_compile_features(${module_name} PRIVATE cxx_std_14) target_compile_features(${module_name} PRIVATE cxx_std_14)
target_compile_options(${module_name} PRIVATE target_compile_options(${module_name} PRIVATE
...@@ -169,15 +161,16 @@ install(FILES ...@@ -169,15 +161,16 @@ install(FILES
## 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 ${CMAKE_PROJECT_NAME}-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")
############################################## ##############################################
## Add test ## Add test
if(TEST) if(TEST)
if(PYBIND) if (AIDGE_REQUIRES_PYTHON AND NOT AIDGE_PYTHON_HAS_EMBED)
message(FATAL_ERROR "PYBIND and TEST are both enabled. But cannot compile with catch_2.\nChoose between pybind and Catch2 for compilation.") message(WARNING "Skipping compilation of tests: missing Python embedded interpreter")
else()
enable_testing()
add_subdirectory(unit_tests)
endif() endif()
enable_testing()
add_subdirectory(unit_tests)
endif() endif()
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(aidge_core)
include(CMakeFindDependencyMacro)
include(${CMAKE_CURRENT_LIST_DIR}/aidge_backend_cpu-config-version.cmake) include(${CMAKE_CURRENT_LIST_DIR}/aidge_backend_cpu-config-version.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/aidge_backend_cpu-targets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/aidge_backend_cpu-targets.cmake)
function(generate_python_binding pybind_module_name target_to_bind) function(generate_python_binding pybind_module_name target_to_bind)
add_definitions(-DPYBIND)
find_package(Python COMPONENTS Interpreter Development.Module)
Include(FetchContent) Include(FetchContent)
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(
...@@ -12,14 +13,12 @@ function(generate_python_binding pybind_module_name target_to_bind) ...@@ -12,14 +13,12 @@ function(generate_python_binding pybind_module_name target_to_bind)
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 ${pybind_module_name}") 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(${pybind_module_name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install 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_include_directories(${pybind_module_name} PRIVATE "python_binding")
target_link_libraries(${pybind_module_name} PUBLIC ${target_to_bind}) target_link_libraries(${pybind_module_name} PRIVATE ${target_to_bind})
endfunction() endfunction()
...@@ -17,7 +17,7 @@ dynamic = ["version"] # defined in tool.setuptools_scm ...@@ -17,7 +17,7 @@ dynamic = ["version"] # defined in tool.setuptools_scm
requires = [ requires = [
"setuptools>=64", "setuptools>=64",
"setuptools_scm[toml]==7.1.0", "setuptools_scm[toml]==7.1.0",
"cmake>=3.15.3.post1" "cmake>=3.18.4.post1"
] ]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
......
...@@ -65,13 +65,14 @@ class AidgePkgBuild(build_ext): ...@@ -65,13 +65,14 @@ class AidgePkgBuild(build_ext):
if build_gen if build_gen
else [] else []
) )
test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF")
self.spawn( self.spawn(
[ [
"cmake", "cmake",
*build_gen_opts, *build_gen_opts,
str(cwd), str(cwd),
"-DTEST=OFF", f"-DTEST={test_onoff}",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
f"-DCMAKE_BUILD_TYPE={compile_type}", f"-DCMAKE_BUILD_TYPE={compile_type}",
"-DPYBIND=ON", "-DPYBIND=ON",
......
...@@ -12,7 +12,7 @@ file(GLOB_RECURSE src_files "*.cpp") ...@@ -12,7 +12,7 @@ file(GLOB_RECURSE src_files "*.cpp")
add_executable(tests${module_name} ${src_files}) add_executable(tests${module_name} ${src_files})
target_link_libraries(tests${module_name} PUBLIC ${module_name}) target_link_libraries(tests${module_name} PRIVATE ${module_name})
target_link_libraries(tests${module_name} PRIVATE Catch2::Catch2WithMain) target_link_libraries(tests${module_name} PRIVATE Catch2::Catch2WithMain)
......
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