mirror of
https://github.com/tdulcet/Table-and-Graph-Libs.git
synced 2025-05-08 00:01:21 +08:00
compile example executables if top level project
This commit is contained in:
parent
9e05996940
commit
17cd9b2de0
@ -1,6 +1,9 @@
|
|||||||
cmake_minimum_required(VERSION 3.19)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(tglib LANGUAGES CXX)
|
project(tglib LANGUAGES CXX)
|
||||||
|
|
||||||
|
# leave compiler options up to parent project, as these libs are header-only
|
||||||
|
|
||||||
|
# create header-only interface target for graphs.hpp
|
||||||
add_library(tglib_graphs INTERFACE)
|
add_library(tglib_graphs INTERFACE)
|
||||||
add_library(${PROJECT_NAME}::graphs ALIAS tglib_graphs)
|
add_library(${PROJECT_NAME}::graphs ALIAS tglib_graphs)
|
||||||
target_sources(tglib_graphs PUBLIC
|
target_sources(tglib_graphs PUBLIC
|
||||||
@ -8,9 +11,20 @@ target_sources(tglib_graphs PUBLIC
|
|||||||
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
|
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
FILES graphs.hpp)
|
FILES graphs.hpp)
|
||||||
|
|
||||||
|
# create header-only interface target for tables.hpp
|
||||||
add_library(tglib_tables INTERFACE)
|
add_library(tglib_tables INTERFACE)
|
||||||
add_library(${PROJECT_NAME}::tables ALIAS tglib_tables)
|
add_library(${PROJECT_NAME}::tables ALIAS tglib_tables)
|
||||||
target_sources(tglib_tables PUBLIC
|
target_sources(tglib_tables PUBLIC
|
||||||
FILE_SET HEADERS
|
FILE_SET HEADERS
|
||||||
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
|
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
FILES tables.hpp)
|
FILES tables.hpp)
|
||||||
|
|
||||||
|
# compile example binaries as executables
|
||||||
|
if (PROJECT_IS_TOP_LEVEL)
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
add_executable(tglib_graphs_example "${CMAKE_CURRENT_SOURCE_DIR}/graphs.cpp")
|
||||||
|
target_link_libraries(tglib_graphs_example PRIVATE tglib::graphs)
|
||||||
|
add_executable(tglib_tables_example "${CMAKE_CURRENT_SOURCE_DIR}/tables.cpp")
|
||||||
|
target_link_libraries(tglib_tables_example PRIVATE tglib::tables)
|
||||||
|
endif()
|
Loading…
Reference in New Issue
Block a user