diff --git a/aidge/_Core/CMakeLists.txt b/aidge/_Core/CMakeLists.txt index 0cd160b05b52710e66878e293819e19b6791e540..a9489b9b4ac0de4d9e381c712fd12231ff8c4c67 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 766aa634ea9dd69da36cc6518c4038432ff24331..d10afab29d3e867632f284ee993929ddaad210ac 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..70ca91e429b310805a72ac0b79ca08645c97f35c 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 +``` +