Skip to content

Commit 7f81ae1

Browse files
committed
FILE_SET is incompatible with frameworks. Revert back to target_include_directories. :`(
1 parent 8ca5b87 commit 7f81ae1

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

cmake/Installation.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ include(CMakePackageConfigHelpers)
44
# Paths
55
if(LSL_UNIXFOLDERS)
66
include(GNUInstallDirs)
7-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
8-
set(FRAMEWORK_DIR_DEFAULT Library/Frameworks)
9-
else()
10-
set(FRAMEWORK_DIR_DEFAULT Frameworks)
11-
endif()
127
set(CMAKE_INSTALL_FRAMEWORK_DIR ${FRAMEWORK_DIR_DEFAULT} CACHE PATH "Install directory for frameworks on macOS")
138
else()
149
set(CMAKE_INSTALL_BINDIR LSL)
@@ -48,8 +43,13 @@ install(TARGETS ${LSLTargets}
4843
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
4944
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
5045
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_DIR}
51-
FILE_SET HEADERS DESTINATION ${LSL_INSTALL_INCLUDEDIR}
5246
)
47+
# Unfortunately, `INCLUDES DESTINATION` does not work.
48+
# PUBLIC_HEADER does not work because it flattens the tree.
49+
# FILE_SET is preferable but does not work with frameworks.
50+
# So we are stuck manually specifying the headers to be installed.
51+
install(DIRECTORY include/lsl DESTINATION ${LSL_INSTALL_INCLUDEDIR})
52+
install(FILES include/lsl_c.h include/lsl_cpp.h DESTINATION ${LSL_INSTALL_INCLUDEDIR})
5353

5454
# Generate the LSLConfig.cmake file and mark it for installation
5555
install(EXPORT LSLTargets

cmake/ProjectOptions.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ option(LSL_TOOLS "Build some experimental tools for in-depth tests" OFF)
1111
option(LSL_UNITTESTS "Build LSL library unit tests" OFF)
1212
option(LSL_FORCE_FANCY_LIBNAME "Add library name decorations (32/64/-debug)" OFF)
1313
mark_as_advanced(LSL_FORCE_FANCY_LIBNAME)
14+
15+
# If we install to the system then we want the framework to land in
16+
# `Library/Frameworks`, otherwise (e.g., Homebrew) we want `Frameworks`
17+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
18+
set(FRAMEWORK_DIR_DEFAULT Library/Frameworks)
19+
else()
20+
set(FRAMEWORK_DIR_DEFAULT Frameworks)
21+
endif()

cmake/TargetLib.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,20 @@ target_link_libraries(lsl PRIVATE lslobj)
3131

3232
# Set the include directories for the lsl target.
3333
# Note: We had to link lslobj as a PRIVATE dependency, therefore we must manually expose the include directories
34-
get_target_property(LSLOBJ_HEADERS lslobj HEADER_SET)
35-
target_sources(lsl
36-
INTERFACE
37-
FILE_SET HEADERS
38-
BASE_DIRS include
39-
FILES ${LSLOBJ_HEADERS}
34+
if(APPLE AND LSL_FRAMEWORK)
35+
# For frameworks, the install interface needs to point into the framework bundle
36+
if(LSL_UNIXFOLDERS)
37+
set(LSL_INSTALL_INTERFACE_INCLUDE_DIR "${FRAMEWORK_DIR_DEFAULT}/lsl.framework/Versions/A/Headers")
38+
else()
39+
set(LSL_INSTALL_INTERFACE_INCLUDE_DIR "LSL/Frameworks/lsl.framework/Versions/A/Headers")
40+
endif()
41+
else()
42+
set(LSL_INSTALL_INTERFACE_INCLUDE_DIR "include")
43+
endif()
44+
target_include_directories(lsl
45+
PUBLIC
46+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
47+
$<INSTALL_INTERFACE:${LSL_INSTALL_INTERFACE_INCLUDE_DIR}>
4048
)
4149

4250
# Set compile definitions for lsl

cmake/TargetObjLib.cmake

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# Create object library so all files are only compiled once
22
add_library(lslobj OBJECT
33
${lslsources}
4-
# ${lslheaders} # Headers are added later using FILE_SET
4+
${lslheaders}
55
)
66

77
# Set the includes/headers for the lslobj target
8-
# Note: We cannot use the PUBLIC_HEADER property of the target,
9-
# because it flattens the include directories.
10-
# Note: IME, this approach is less error prone than target_include_directories
11-
target_sources(lslobj
12-
INTERFACE
13-
FILE_SET HEADERS # special set name; implies TYPE.
14-
BASE_DIRS include
15-
FILES ${lslheaders}
8+
# Note: We cannot use PUBLIC_HEADER because it flattens the include tree upon install
9+
# Note: We cannot use FILE_SET because it is not compatible with HEADERS.
10+
target_include_directories(lslobj
11+
PUBLIC
12+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
13+
$<INSTALL_INTERFACE:include> # For targets that link to the installed lslobj
1614
)
1715

1816
# Link system libs

0 commit comments

Comments
 (0)