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)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
......@@ -76,13 +76,6 @@ if (PYBIND)
include(PybindModuleCreation)
generate_python_binding(${pybind_module_name} ${module_name})
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Module
)
endif()
if( ${ENABLE_ASAN} )
......@@ -106,7 +99,6 @@ target_include_directories(${module_name}
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(${module_name} PUBLIC fmt::fmt)
target_compile_features(${module_name} PRIVATE cxx_std_14)
target_compile_options(${module_name} PRIVATE
......@@ -169,15 +161,16 @@ install(FILES
## Exporting from the build tree
message(STATUS "Exporting created targets to use them in another build")
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
if(TEST)
if(PYBIND)
message(FATAL_ERROR "PYBIND and TEST are both enabled. But cannot compile with catch_2.\nChoose between pybind and Catch2 for compilation.")
if (AIDGE_REQUIRES_PYTHON AND NOT AIDGE_PYTHON_HAS_EMBED)
message(WARNING "Skipping compilation of tests: missing Python embedded interpreter")
else()
enable_testing()
add_subdirectory(unit_tests)
endif()
enable_testing()
add_subdirectory(unit_tests)
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-targets.cmake)
function(generate_python_binding pybind_module_name target_to_bind)
add_definitions(-DPYBIND)
find_package(Python COMPONENTS Interpreter Development.Module)
Include(FetchContent)
set(PYBIND_VERSION v2.10.4)
set(PYBIND11_FINDPYTHON ON)
message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git")
FetchContent_Declare(
......@@ -12,14 +13,12 @@ function(generate_python_binding pybind_module_name target_to_bind)
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 ${pybind_module_name}")
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
target_include_directories(${pybind_module_name} PUBLIC "python_binding")
target_link_libraries(${pybind_module_name} PUBLIC ${target_to_bind})
target_include_directories(${pybind_module_name} PRIVATE "python_binding")
target_link_libraries(${pybind_module_name} PRIVATE ${target_to_bind})
endfunction()
......@@ -17,7 +17,7 @@ dynamic = ["version"] # defined in tool.setuptools_scm
requires = [
"setuptools>=64",
"setuptools_scm[toml]==7.1.0",
"cmake>=3.15.3.post1"
"cmake>=3.18.4.post1"
]
build-backend = "setuptools.build_meta"
......
......@@ -65,13 +65,14 @@ class AidgePkgBuild(build_ext):
if build_gen
else []
)
test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF")
self.spawn(
[
"cmake",
*build_gen_opts,
str(cwd),
"-DTEST=OFF",
f"-DTEST={test_onoff}",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
f"-DCMAKE_BUILD_TYPE={compile_type}",
"-DPYBIND=ON",
......
......@@ -12,7 +12,7 @@ file(GLOB_RECURSE src_files "*.cpp")
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)
......
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