-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite build logic with mordernized CMake format
- Loading branch information
Showing
28 changed files
with
749 additions
and
17,815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,76 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
set(CMAKE_CXX_STANDARD 11) | ||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||
|
||
# ---- Project ---- | ||
|
||
project(libdaylight) | ||
include(cmake/WriteVersionInfo.cmake) | ||
# Get version from VERSION file instead of hardcoding here | ||
# This is so that we can maintain a single version across C++ and Python | ||
execute_process(COMMAND python tools/print_version.py OUTPUT_VARIABLE DAYLIGHT_VERSION) | ||
set(PROJECT_VERSION ${DAYLIGHT_VERSION}) | ||
|
||
message(${DAYLIGHT_VERSION}) | ||
|
||
if(NOT DEFINED MSVC) | ||
set(BUILD_SHARED_LIBS ON) | ||
# ---- Include guards ---- | ||
|
||
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) | ||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.") | ||
endif() | ||
|
||
enable_testing() | ||
# ---- Dependencies ---- | ||
# For more info on CPM dependecies, see https://github.com/TheLartians/CPM.cmake | ||
|
||
include(cmake/CPM.cmake) | ||
|
||
# PackageProject.cmake will be used to make our target installable | ||
CPMAddPackage( | ||
NAME PackageProject.cmake | ||
GITHUB_REPOSITORY TheLartians/PackageProject.cmake | ||
VERSION 1.3 | ||
) | ||
|
||
# ---- Add source files ---- | ||
|
||
# Note: globbing sources is considered bad practice as CMake's generators may not detect new files automatically. | ||
# Keep that in mind when changing files, or explicitly mention them here. | ||
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp") | ||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") | ||
|
||
# ---- Create library ---- | ||
|
||
add_library(libdaylight ${headers} ${sources}) | ||
|
||
set_target_properties(libdaylight PROPERTIES | ||
CXX_STANDARD 11 | ||
POSITION_INDEPENDENT_CODE ON | ||
PREFIX "" | ||
) | ||
|
||
if(MSVC) | ||
add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
endif() | ||
|
||
# being a cross-platform target, we enforce standards conformance on MSVC | ||
target_compile_options(libdaylight PUBLIC "$<$<BOOL:${MSVC}>:/permissive->") | ||
|
||
target_include_directories(libdaylight | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}> | ||
) | ||
|
||
# ---- Create an installable target ---- | ||
# this allows users to install and find the library via `find_package()`. | ||
|
||
# Ensures all git submodules are present | ||
execute_process(COMMAND git submodule update --init --recursive) | ||
# the location where the project's version header will be placed | ||
# should match the project's regular header paths | ||
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION) | ||
|
||
add_subdirectory(libdaylight) | ||
add_subdirectory(capi) | ||
add_subdirectory(tests) | ||
add_subdirectory(vendor/pybind11) | ||
add_subdirectory(pybind) | ||
add_subdirectory(docs) | ||
packageProject( | ||
NAME ${PROJECT_NAME} | ||
VERSION ${PROJECT_VERSION} | ||
BINARY_DIR ${PROJECT_BINARY_DIR} | ||
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include | ||
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} | ||
VERSION_HEADER "${VERSION_HEADER_LOCATION}" | ||
DEPENDENCIES "" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
file(GLOB_RECURSE _sources ${CMAKE_CURRENT_LIST_DIR}/*.cpp) | ||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | ||
|
||
add_library(libdaylight_c ${_sources}) | ||
set_target_properties(libdaylight_c PROPERTIES PREFIX "") | ||
set_target_properties(libdaylight_c PROPERTIES SUFFIX "-${LIBDAYLIGHT_VERSION}.so") | ||
target_link_libraries(libdaylight_c PRIVATE libdaylight) | ||
project( | ||
daylight_c | ||
LANGUAGES CXX | ||
) | ||
|
||
# ---- Dependencies ---- | ||
|
||
include(../cmake/CPM.cmake) | ||
|
||
CPMAddPackage( | ||
NAME libdaylight | ||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/.. | ||
) | ||
|
||
# ---- Create library ---- | ||
|
||
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") | ||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") | ||
add_library(daylight_c ${headers} ${sources}) | ||
target_link_libraries(daylight_c libdaylight) | ||
|
||
set_target_properties(daylight_c PROPERTIES CXX_STANDARD 11) | ||
|
||
# being a cross-platform target, we enforce standards conformance on MSVC | ||
target_compile_options(daylight_c PUBLIC "$<$<BOOL:${MSVC}>:/permissive->") | ||
|
||
target_include_directories(daylight_c | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.