Skip to content

Commit 018f690

Browse files
committed
Cleanup CMake reundancies and use FILE_SET for headers -- only solution that installed non-flat header tree by transitive dependencies.
1 parent a51c463 commit 018f690

File tree

5 files changed

+14
-68
lines changed

5 files changed

+14
-68
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.16)
1+
cmake_minimum_required (VERSION 3.23)
22
project (liblsl
33
VERSION 1.16.2
44
LANGUAGES C CXX

cmake/Installation.cmake

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,22 @@ write_basic_package_version_file(
1818
)
1919

2020
# Define installation targets
21-
set(LSLTargets lsl)
22-
if(LSL_BUILD_STATIC)
23-
list(APPEND LSLTargets lslobj lslboost)
24-
endif()
21+
set(LSLTargets lsl lslobj lslboost)
2522

2623
# Install the targets and store configuration information.
2724
install(TARGETS ${LSLTargets}
28-
EXPORT LSLTargets # generates a CMake package config; TODO: Why the same name as the list of targets?
25+
EXPORT LSLTargets
2926
COMPONENT liblsl
3027
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3128
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
3229
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
33-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
34-
# If we use CMake 3.23 FILE_SET, replace INCLUDES line with: FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
35-
)
36-
37-
# TODO: What does this do? Why do we need LSLTargets.cmake in the build dir?
38-
export(EXPORT LSLTargets
39-
FILE "${CMAKE_CURRENT_BINARY_DIR}/LSLTargets.cmake"
40-
NAMESPACE LSL::
30+
# INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
31+
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
4132
)
4233

4334
# Generate the LSLConfig.cmake file and mark it for installation
4435
install(EXPORT LSLTargets
45-
FILE LSLTargets.cmake # TODO: I think we can use this to generate LSLConfig.cmake, no?
36+
FILE LSLConfig.cmake
4637
COMPONENT liblsl
4738
NAMESPACE "LSL::"
4839
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LSL
@@ -53,28 +44,10 @@ install(EXPORT LSLTargets
5344
# INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lsl)
5445
# If we use this method, then we need a corresponding install(FILES ...) command to install the generated file.
5546

56-
# Copy hardcoded CMake files to the build directory.
57-
# TODO: Why bother with this copy? Is it not enough to install (into cmake/LSL)?
58-
configure_file(cmake/LSLCMake.cmake "${CMAKE_CURRENT_BINARY_DIR}/LSLCMake.cmake" COPYONLY)
59-
# TODO: Why bother with this copy? Is it not enough to install (into cmake/LSL)?
60-
# TODO: Why use hardcoded files? We can generate the LSLConfig.cmake.
61-
configure_file(cmake/LSLConfig.cmake "${CMAKE_CURRENT_BINARY_DIR}/LSLConfig.cmake" COPYONLY)
62-
63-
# Install the public headers.
64-
# TODO: Verify that this is necessary, given that we already installed the INCLUDES above.
65-
# TODO: Verify if it is still necessary to install the headers if we use FILE_SET.
66-
install(DIRECTORY include/
67-
COMPONENT liblsl
68-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
69-
)
70-
7147
# Install the version file and the helper CMake script.
7248
install(
7349
FILES
74-
# TODO: Keep this. But why does the configure_file(... COPYONLY) above exist?
7550
cmake/LSLCMake.cmake
76-
# TODO: Next line shouldn't be necessary if install(EXPORT...) uses LSLConfig.cmake instead of LSLTargets.cmake
77-
${CMAKE_CURRENT_BINARY_DIR}/LSLConfig.cmake
7851
${CMAKE_CURRENT_BINARY_DIR}/LSLConfigVersion.cmake
7952
COMPONENT liblsl
8053
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LSL

cmake/LSLConfig.cmake

Lines changed: 0 additions & 8 deletions
This file was deleted.

cmake/TargetLib.cmake

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,11 @@ if(LSL_FORCE_FANCY_LIBNAME)
2323
)
2424
endif()
2525

26-
# Includes. TODO: Can we not inherit these from lslobj?
27-
target_include_directories(lsl
28-
INTERFACE
29-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
30-
$<INSTALL_INTERFACE:include>
31-
)
3226

3327
# Link dependencies. The biggest dependency is lslobj, which contains the bulk of the library code.
3428
target_link_libraries(lsl
3529
PRIVATE
36-
lslobj # TODO: If this is public, does that improve inheritance of includes and compile definitions?
37-
lslboost # TODO: Shouldn't be needed -- lslobj already links it
30+
lslobj
3831
${PUGIXML_LIBRARIES}
3932
)
4033

cmake/TargetObjLib.cmake

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@ add_library(lslobj OBJECT
88
# Note: We cannot use the PUBLIC_HEADER property of the target, because
99
# it flattens the include directories.
1010
# We could use the new FILE_SET feature that comes with CMake 3.23.
11-
# This is how it would look. Note that HEADERS is a special set name and implies its type.
12-
#target_sources(lslobj
13-
# PUBLIC
14-
# FILE_SET HEADERS
15-
# BASE_DIRS include
16-
# FILES ${lslheaders}
17-
#)
18-
# We settle on the older and more common target_include_directories PUBLIC approach.
19-
# If we used the FILET_SET approach then we would remove the PUBLIC includes below.
20-
target_include_directories(lslobj
11+
# Note that HEADERS is a special set name and implies its type.
12+
target_sources(lslobj
2113
PUBLIC
22-
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
23-
$<INSTALL_INTERFACE:include>
14+
FILE_SET HEADERS
15+
BASE_DIRS include
16+
FILES ${lslheaders}
17+
)
18+
target_include_directories(lslobj
2419
INTERFACE
25-
# Propagate include directories to consumers
2620
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> # for unit tests
2721
)
2822

@@ -61,12 +55,6 @@ if(WIN32)
6155
PUBLIC
6256
_WIN32_WINNT=${LSL_WINVER}
6357
)
64-
if(BUILD_SHARED_LIBS)
65-
# set_target_properties(lslobj
66-
# PROPERTIES
67-
# WINDOWS_EXPORT_ALL_SYMBOLS ON
68-
# )
69-
endif(BUILD_SHARED_LIBS)
7058
endif(WIN32)
7159

7260
# Link in 3rd party dependencies

0 commit comments

Comments
 (0)