From 41e0f1b40b4faffd3fecd3e9f5a6624659598d85 Mon Sep 17 00:00:00 2001 From: Vincent TEMPLIER <vincent.templier@cea.fr> Date: Wed, 26 Jul 2023 12:30:21 +0000 Subject: [PATCH] Add BUILD_CORE_ALONE mode to compile Core library --- aidge/_Core/CMakeLists.txt | 35 +++++++++++++++++++++++++++++------ aidge/_Core/Makefile | 35 ++++++++++++++++++++++++++++++++++- aidge/_Core/README.md | 28 ++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/aidge/_Core/CMakeLists.txt b/aidge/_Core/CMakeLists.txt index 0cd160b0..a9489b9b 100644 --- a/aidge/_Core/CMakeLists.txt +++ b/aidge/_Core/CMakeLists.txt @@ -1,8 +1,25 @@ -# project(Aidge_Core) +if (BUILD_CORE_ALONE) + project(Aidge_Core) + cmake_minimum_required(VERSION 3.11) + add_compile_options(-Wall -Wextra -fPIC) +endif() if (PYBIND) - generate_python_binding(aidge_core core) + Include(FetchContent) + + FetchContent_Declare( + PyBind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG v2.10.4 # or a later release + ) + + FetchContent_MakeAvailable(PyBind11) + file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") + pybind11_add_module(aidge_core MODULE ${pybind_src_files} "NO_EXTRAS") + target_include_directories(aidge_core PUBLIC ${pybind11_INCLUDE_DIRS} "python_binding") + target_link_libraries(aidge_core PUBLIC core) + # generate_python_binding(aidge_core core) endif() add_library(core STATIC) @@ -21,8 +38,14 @@ if (PYBIND) target_link_libraries(core PRIVATE ${PYTHON_LIBRARIES}) endif() +if (NOT BUILD_CORE_ALONE) + # Activate compile time reducer for aidge_core + set_target_properties(core PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) + # set_target_properties(n2d2_cpu_lib PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "include/utils/Precompiled.hpp") + cotire(core) +endif() + -# Activate compile time reducer for aidge_core -set_target_properties(core PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) -# set_target_properties(n2d2_cpu_lib PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "include/utils/Precompiled.hpp") -cotire(core) \ No newline at end of file +if (TESTS) + add_subdirectory(tests) +endif() \ No newline at end of file diff --git a/aidge/_Core/Makefile b/aidge/_Core/Makefile index 766aa634..d10afab2 100644 --- a/aidge/_Core/Makefile +++ b/aidge/_Core/Makefile @@ -1,3 +1,36 @@ # This makefile does nothing but delegating the actual building to cmake BUILDDIR := build -MAKEFLAGS := --no-print-directory \ No newline at end of file +MAKEFLAGS := --no-print-directory + +all: core_with_pybind + +core_only: + mkdir -p ${BUILDDIR}; \ + cd ${BUILDDIR}; \ + cmake -DBUILD_CORE_ALONE=ON -DCMAKE_BUILD_TYPE=Release -DPYBIND=OFF -DTESTS=OFF ..; \ + ${MAKE} ${MAKEFLAGS}; + +core_tests: + mkdir -p ${BUILDDIR}; \ + cd ${BUILDDIR}; \ + cmake -DBUILD_CORE_ALONE=ON -DCMAKE_BUILD_TYPE=Debug -DPYBIND=OFF -DTESTS=ON ..; \ + ${MAKE} ${MAKEFLAGS}; \ + cd tests; \ + ctest --output-on-failure || true; + +core_with_pybind: + mkdir -p ${BUILDDIR}; \ + cd ${BUILDDIR}; \ + cmake -DBUILD_CORE_ALONE=ON -DCMAKE_BUILD_TYPE=Release -DPYBIND=ON -DTESTS=OFF ..; \ + ${MAKE} ${MAKEFLAGS}; + +core_with_pybind_tests: + mkdir -p ${BUILDDIR}; \ + cd ${BUILDDIR}; \ + cmake -DBUILD_CORE_ALONE=ON -DCMAKE_BUILD_TYPE=Debug -DPYBIND=ON -DTESTS=ON ..; \ + ${MAKE} ${MAKEFLAGS}; \ + cd tests; \ + ctest --output-on-failure || true; + +clean: + if [ -d "${BUILDDIR}" ]; then rm -rf ${BUILDDIR}; fi \ No newline at end of file diff --git a/aidge/_Core/README.md b/aidge/_Core/README.md index e69de29b..70ca91e4 100644 --- a/aidge/_Core/README.md +++ b/aidge/_Core/README.md @@ -0,0 +1,28 @@ +# Aidge Core library + +You can find here the C++ code of the Core library of Aidge. + +## Compilation + +To only compile the Core library, run +``` +make core_only +``` + +To compile the Core library + the associated unitary tests, run +``` +make core_tests +``` + +To compile the Core library with the python binding, run +``` +make core_with_pybind +``` +Important: this command can also be run with `make`. + + +To compile the Core library with the python binding + the associated unitary tests, run +``` +make core_with_pybind_tests +``` + -- GitLab