Skip to content
Snippets Groups Projects
Commit 59855419 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Update module to new CmakeLists.txt.

parent 9a94f3ad
No related branches found
No related tags found
No related merge requests found
Showing
with 243 additions and 76 deletions
cmake_minimum_required(VERSION 3.11)
if (BUILD_CORE_ALONE)
project(Aidge_Core)
cmake_minimum_required(VERSION 3.11)
add_compile_options(-Wall -Wextra -fPIC)
endif()
if (PYBIND)
add_definitions(-DPYBIND)
Include(FetchContent)
set(project aidge)
set(version 2.0.0)
project(${project})
enable_testing()
# TODO : use a file to store module_name ?
set(module_name aidge_core) # This will be python module name
set(component core) # Traget name must be different than pybind target
FetchContent_Declare(
PyBind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.10.4 # or a later release
)
##############################################
# Import utils CMakeLists
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(PybindModuleCreation)
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()
##############################################
# Define options
option(PYBIND "python binding" ON)
option(WERROR "Warning as error" OFF)
add_library(core STATIC)
##############################################
# Find system dependencies
generate_python_binding(aidge_${module_name}) # TODO : cannot be component because of target name
# Add include directories
target_include_directories(core PUBLIC "include")
##############################################
# Create target and set properties
# Containers module
file(GLOB_RECURSE src_files "src/*.cpp")
target_sources(core PRIVATE ${src_files})
file(GLOB_RECURSE inc_files "include/*.hpp")
add_library(${component} ${src_files} ${inc_files})
set_property(TARGET core PROPERTY POSITION_INDEPENDENT_CODE ON)
# namespaced alias
add_library(${project}::${component} ALIAS ${component})
#Set target properties
set_property(TARGET ${component} PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(${component}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
if (PYBIND)
target_include_directories(core PUBLIC $<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>)
target_link_libraries(core PRIVATE ${PYTHON_LIBRARIES})
endif()
message(STATUS "PYTHON INCLUDE DIR : ${PYTHON_INCLUDE_DIRS}")
message(STATUS "PYTHON PYTHON_LIBRARY : ${PYTHON_LIBRARIES}")
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)
target_include_directories(${component}
PUBLIC
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>
)
target_link_libraries(${component}
PRIVATE
${PYTHON_LIBRARIES}
)
endif()
target_compile_features(${component} PRIVATE cxx_std_14)
if(WERROR)
target_compile_options(${component} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wold-style-cast -Winline -pedantic -Werror=narrowing -Wshadow -Werror>)
target_compile_options(${component} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)
else()
target_compile_options(${component} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wold-style-cast -Winline -pedantic -Werror=narrowing -Wshadow -Wpedantic>)
target_compile_options(${component} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)
endif()
##############################################
# Installation instructions
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${project})
install(TARGETS ${component} EXPORT ${component}-targets
COMPONENT ${component}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#Export the targets to a script
install(EXPORT ${component}-targets
FILE "${project}-${component}-targets.cmake"
NAMESPACE ${project}::
DESTINATION ${INSTALL_CONFIGDIR}
COMPONENT ${component}
)
#Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${project}-${component}-config-version.cmake"
VERSION ${version}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file("${component}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-${component}-config.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
#Install the config, configversion and custom find modules
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${project}-${component}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-${component}-config-version.cmake"
DESTINATION ${INSTALL_CONFIGDIR}
COMPONENT ${component}
)
##############################################
## Exporting from the build tree
export(EXPORT ${component}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-${component}-targets.cmake"
NAMESPACE ${project}::)
##############################################
## Add test
add_subdirectory(unit_tests)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${project}-config-version.cmake"
VERSION ${version}
COMPATIBILITY AnyNewerVersion
)
if (TESTS)
add_subdirectory(tests)
endif()
\ No newline at end of file
# install(
# FILES
# "${CMAKE_BINARY_DIR}/${project}-config.cmake"
# DESTINATION lib/cmake/${project}
# )
if (BUILD_CORE_ALONE)
project(Aidge_Core)
cmake_minimum_required(VERSION 3.11)
add_compile_options(-Wall -Wextra -fPIC)
endif()
if (PYBIND)
add_definitions(-DPYBIND)
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)
# Add include directories
target_include_directories(core PUBLIC "include")
# Containers module
file(GLOB_RECURSE src_files "src/*.cpp")
target_sources(core PRIVATE ${src_files})
set_property(TARGET core PROPERTY POSITION_INDEPENDENT_CODE ON)
if (PYBIND)
target_include_directories(core PUBLIC $<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>)
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()
if (TESTS)
add_subdirectory(tests)
endif()
\ No newline at end of file
function(generate_python_binding name)
if (PYBIND)
add_definitions(-DPYBIND)
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)
message(STATUS "Creating binding for module ${name}")
file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp")
pybind11_add_module(${name} MODULE ${pybind_src_files})
target_include_directories(${name} PUBLIC ${pybind11_INCLUDE_DIRS} "python_binding")
target_link_libraries(${name} PUBLIC ${component})
endif()
endfunction()
include(${CMAKE_CURRENT_LIST_DIR}/aidge_core-config-version.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/aidge_core-targets.cmake)
......@@ -14,7 +14,7 @@
#include <cstddef>
#include <vector>
#include "utils/Types.h"
#include "aidge/utils/Types.h"
namespace Aidge {
class OperatorImpl {
......
......@@ -14,7 +14,7 @@
#include <cstddef>
#include <cstdio>
#include "utils/Types.h"
#include "aidge/utils/Types.h"
namespace Aidge {
class TensorImpl {
......
......@@ -12,7 +12,7 @@
#ifndef __AIDGE_DATA_H__
#define __AIDGE_DATA_H__
#include "utils/Parameter.hpp"
#include "aidge/utils/Parameter.hpp"
namespace Aidge {
enum class DataType {
......
......@@ -19,10 +19,10 @@
#include <string>
#include <vector>
#include "backend/TensorImpl.hpp"
#include "data/Data.hpp"
#include "utils/Registrar.hpp"
#include "utils/Types.h"
#include "aidge/backend/TensorImpl.hpp"
#include "aidge/data/Data.hpp"
#include "aidge/utils/Registrar.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
......
......@@ -15,7 +15,7 @@
#include <memory>
#include <vector>
#include "utils/Types.h"
#include "aidge/utils/Types.h"
namespace Aidge {
......
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
......@@ -19,8 +20,8 @@
#include <utility>
#include <vector>
#include "graph/Node.hpp"
#include "utils/Types.h"
#include "aidge/graph/Node.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
enum class DataType;
......
......@@ -19,9 +19,9 @@
#include <vector>
#include <utility>
#include "graph/Connector.hpp"
#include "operator/Operator.hpp"
#include "utils/Types.h"
#include "aidge/graph/Connector.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
......
File moved
......@@ -18,11 +18,11 @@
#include <memory> // for shared_ptr
#include <algorithm> // for next_permutation
#include "graphmatching/Utile.hpp"
#include "graphmatching/StmFactory.hpp"
#include "graphmatching/SeqStm.hpp"
#include "graphmatching/NodeRegex.hpp"
#include "graphmatching/Match.hpp"
#include "aidge/graphmatching/Utile.hpp"
#include "aidge/graphmatching/StmFactory.hpp"
#include "aidge/graphmatching/SeqStm.hpp"
#include "aidge/graphmatching/NodeRegex.hpp"
#include "aidge/graphmatching/Match.hpp"
namespace Aidge{
......
......@@ -16,7 +16,7 @@
#include <set>
#include <iostream>
#include <cassert>
#include "graphmatching/Utile.hpp"
#include "aidge/graphmatching/Utile.hpp"
namespace Aidge{
......
......@@ -14,7 +14,7 @@
#include <cstdlib>
#include <iostream>
#include <cstring>
#include "graph/Node.hpp"
#include "aidge/graph/Node.hpp"
namespace Aidge {
......
......@@ -22,8 +22,8 @@
#include <vector>
#include "graphmatching/NodeRegex.hpp"
#include "graphmatching/Utile.hpp"
#include "aidge/graphmatching/NodeRegex.hpp"
#include "aidge/graphmatching/Utile.hpp"
namespace Aidge {
......
......@@ -21,9 +21,9 @@
#include <stdexcept> // for exception, runtime_error, out_of_range
#include <regex>
#include "graphmatching/NodeRegex.hpp"
#include "graphmatching/SeqStm.hpp"
#include "graphmatching/Utile.hpp"
#include "aidge/graphmatching/NodeRegex.hpp"
#include "aidge/graphmatching/SeqStm.hpp"
#include "aidge/graphmatching/Utile.hpp"
namespace Aidge{
......
......@@ -14,7 +14,7 @@
#include <map>
#include "graph/Node.hpp"
#include "aidge/graph/Node.hpp"
#include <map>
namespace Aidge {
......
......@@ -18,11 +18,11 @@
#include <memory>
#include <array>
#include "utils/Registrar.hpp"
#include "operator/Operator.hpp"
#include "data/Tensor.hpp"
#include "graph/Node.hpp"
#include "utils/Types.h"
#include "aidge/utils/Registrar.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/data/Tensor.hpp"
#include "aidge/graph/Node.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
......
......@@ -17,13 +17,13 @@
#include <vector>
#include <cmath>
#include "data/Tensor.hpp"
#include "graph/Node.hpp"
#include "operator/Operator.hpp"
#include "operator/Producer.hpp"
#include "utils/Parameter.hpp"
#include "utils/Registrar.hpp"
#include "utils/Types.h"
#include "aidge/data/Tensor.hpp"
#include "aidge/graph/Node.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/operator/Producer.hpp"
#include "aidge/utils/Parameter.hpp"
#include "aidge/utils/Registrar.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
enum class AvgPoolingParam { StrideDims, KernelDims, PaddingDims };
......
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