Skip to content

Commit 521c1f9

Browse files
committed
working examples without filesets but with separate library targets
1 parent 77fc7ea commit 521c1f9

File tree

5 files changed

+20
-80
lines changed

5 files changed

+20
-80
lines changed

CMake/ystdlib-cpp-helpers.cmake

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,10 @@ function(cpp_library)
103103
)
104104
target_compile_features(${arg_cpp_lib_NAME} INTERFACE cxx_std_20)
105105

106-
target_sources(
107-
${arg_cpp_lib_NAME}
108-
INTERFACE
109-
FILE_SET HEADERS
110-
FILES
111-
${arg_cpp_lib_PUBLIC_HEADERS}
112-
)
113-
114-
# get_target_property(hdrs ${arg_cpp_lib_NAME} HEADER_SET)
115-
# set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${arg_cpp_lib_NAME}")
116-
# install(
117-
# FILES
118-
# ${hdrs}
119-
# DESTINATION "${INSTALL_INCLUDE_DIR}"
120-
# )
121-
122-
# target_include_directories(${arg_cpp_lib_NAME} INTERFACE include)
123-
124-
# set(INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${arg_cpp_lib_NAME}")
125-
# set(PREFIXED_SOURCES "")
126-
# foreach(FILE ${arg_cpp_lib_PUBLIC_HEADERS})
127-
# list(APPEND PREFIXED_SOURCES "${INCLUDE_DIR}/${FILE}")
128-
# endforeach()
129-
130-
# message(${arg_cpp_lib_PUBLIC_HEADERS})
131-
# target_include_DIRECTORIES(
132-
# ${arg_cpp_lib_NAME}
133-
# INTERFACE
134-
# ${arg_cpp_lib_PUBLIC_HEADERS}
135-
# )
106+
# tells where headers are
107+
target_include_directories(${arg_cpp_lib_NAME} INTERFACE
108+
# "$<INSTALL_INTERFACE:include/${arg_cpp_lib_NAME}>")
109+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
136110

137111
else()
138112
# The library type is specified by `BUILD_SHARED_LIBS` if it is defined. Otherwise, the type
@@ -161,12 +135,13 @@ function(cpp_library)
161135

162136
add_library(${_ALIAS_TARGET_NAME} ALIAS ${arg_cpp_lib_NAME})
163137

164-
# set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${arg_cpp_lib_NAME}")
165-
# install(
166-
# FILES
167-
# ${arg_cpp_lib_PUBLIC_HEADERS}
168-
# DESTINATION "${INSTALL_INCLUDE_DIR}"
169-
# )
138+
# install headers
139+
set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/ystdlib/${arg_cpp_lib_NAME}")
140+
install(
141+
FILES
142+
${arg_cpp_lib_PUBLIC_HEADERS}
143+
DESTINATION "${INSTALL_INCLUDE_DIR}"
144+
)
170145

171146
set_target_properties(
172147
${arg_cpp_lib_NAME}

CMakeLists.txt

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,6 @@ endif()
8787
set(ystdlib_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/ystdlib)
8888
set(ystdlib_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
8989

90-
# file(
91-
# GLOB_RECURSE SOURCE_FILES
92-
# CONFIGURE_DEPENDS
93-
# "${PROJECT_SOURCE_DIR}/src/*.cpp"
94-
# "${PROJECT_SOURCE_DIR}/src/*.hpp"
95-
# "${PROJECT_SOURCE_DIR}/src/*.h"
96-
# )
97-
# list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_*\..*")
98-
#
99-
# add_library(ystdlib ${SOURCE_FILES})
100-
# add_library(ystdlib::ystdlib ALIAS ystdlib)
101-
102-
# target_include_directories(
103-
# ystdlib
104-
# PUBLIC
105-
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
106-
# $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
107-
# )
108-
109-
# target_compile_features(ystdlib PUBLIC cxx_std_20)
110-
111-
# set_target_properties(
112-
# ystdlib
113-
# PROPERTIES
114-
# LINKER_LANGUAGE
115-
# CXX
116-
# )
117-
11890
add_subdirectory(src/ystdlib)
11991

12092
install(TARGETS
@@ -131,19 +103,6 @@ install(TARGETS
131103

132104
install(EXPORT ystdlib-targets NAMESPACE ystdlib:: DESTINATION ${ystdlib_INSTALL_CONFIG_DIR})
133105

134-
# install(
135-
# DIRECTORY
136-
# "${PROJECT_SOURCE_DIR}/src/ystdlib"
137-
# DESTINATION "${ystdlib_INSTALL_INCLUDE_DIR}"
138-
# FILES_MATCHING
139-
# PATTERN
140-
# "*.h"
141-
# PATTERN
142-
# "*.hpp"
143-
# PATTERN
144-
# "*.tpp"
145-
# )
146-
147106
configure_package_config_file(
148107
${CMAKE_CURRENT_LIST_DIR}/CMake/ystdlib-config.cmake.in
149108
${CMAKE_CURRENT_BINARY_DIR}/ystdlib-config.cmake

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(ystdlib-examples_IS_TOP_LEVEL)
77
include("${CMAKE_SOURCE_DIR}/../build/deps/cmake-settings/settings.cmake" OPTIONAL)
88
endif()
99

10-
set(ystdlib_ROOT "/home/john/docs/yscope/ystdlib-cpp/build/build_install")
10+
set(ystdlib_ROOT "${CMAKE_SOURCE_DIR}/../build/build_install")
1111
find_package(ystdlib REQUIRED)
1212

1313
add_library(

examples/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
cmake .. -C ../../build/build_install/lib64/cmake/ystdlib/ystdlib-config.cmake
1+
cmake ..
22

33
Run above command from examples/build
4+
5+
Dependencies:
6+
7+
After building main project, cd to build and run
8+
9+
cmake --install . --prefix=build_install to have an install location

examples/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
#include <error_handling/ErrorCode.hpp>
6+
#include <ystdlib/error_handling/ErrorCode.hpp>
77

88
namespace ystdlib::error_handling::test {
99
enum class AlwaysSuccessErrorCodeEnum : uint8_t {

0 commit comments

Comments
 (0)