Skip to content

Commit 5a3fec9

Browse files
committed
apple.26
Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent 489c66b commit 5a3fec9

2 files changed

Lines changed: 79 additions & 29 deletions

File tree

config/CMakeLists.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ set(IMATH_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "")
1616
add_library(ImathConfig INTERFACE)
1717
add_library(Imath::Config ALIAS ImathConfig)
1818

19-
target_include_directories(ImathConfig INTERFACE
20-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
21-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
22-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR}>)
19+
if (IMATH_BUILD_APPLE_FRAMEWORK)
20+
# apple framework installs includes in Imath.framework/Headers, not include/Imath
21+
target_include_directories(ImathConfig INTERFACE
22+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
23+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/Imath.framework/Headers>
24+
)
25+
else()
26+
target_include_directories(ImathConfig INTERFACE
27+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
28+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR}>
29+
)
30+
endif()
2331

2432
if (IMATH_INSTALL)
2533
install(TARGETS ImathConfig EXPORT Imath)
@@ -71,7 +79,12 @@ set(IMATH_CMAKE_CONFIG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
7179
file(MAKE_DIRECTORY ${IMATH_CMAKE_CONFIG_BUILD_DIR})
7280

7381
if(APPLE AND IMATH_BUILD_APPLE_FRAMEWORK)
74-
set(cmake_destination Imath.framework/Versions/${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}/Resources/CMake/Imath)
82+
# macOS framework versions the Resources and headers, iOS does not
83+
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
84+
set(cmake_destination Imath.framework/Resources/CMake/Imath)
85+
else()
86+
set(cmake_destination Imath.framework/Versions/${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}/Resources/CMake/Imath)
87+
endif()
7588
else()
7689
set(cmake_destination ${CMAKE_INSTALL_LIBDIR}/cmake/Imath)
7790
endif()
@@ -94,15 +107,4 @@ if (IMATH_INSTALL)
94107
DESTINATION ${cmake_destination}
95108
)
96109

97-
install(EXPORT Imath
98-
DESTINATION ${cmake_destination}
99-
FILE ImathTargets.cmake
100-
NAMESPACE Imath::
101-
EXPORT_LINK_INTERFACE_LIBRARIES
102-
)
103-
104-
export(EXPORT Imath
105-
FILE "${CMAKE_CURRENT_BINARY_DIR}/ImathTargets.cmake"
106-
NAMESPACE Imath::
107-
)
108110
endif()

src/Imath/CMakeLists.txt

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,20 @@ endif()
107107

108108
set_property(TARGET ${IMATH_LIBRARY} PROPERTY PUBLIC_HEADER ${IMATH_HEADERS})
109109

110-
target_include_directories(${IMATH_LIBRARY} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
110+
# Includes are installed to "include/Imath", or under Imath.framework/Headers for apple framework
111+
if (IMATH_BUILD_APPLE_FRAMEWORK)
112+
target_include_directories(${IMATH_LIBRARY}
113+
PUBLIC
114+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
115+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/Imath.framework/Headers>
116+
)
117+
else()
118+
target_include_directories(${IMATH_LIBRARY}
119+
INTERFACE
120+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
121+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR}>
122+
)
123+
endif()
111124

112125
#
113126
# Link options
@@ -122,16 +135,30 @@ if (HAVE_LIB_M)
122135
endif()
123136

124137
if (IMATH_BUILD_APPLE_FRAMEWORK)
125-
set_target_properties(${IMATH_LIBRARY} PROPERTIES
126-
FRAMEWORK TRUE
127-
FRAMEWORK_VERSION "${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}"
128-
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.aswf.Imath"
129-
MACOSX_FRAMEWORK_IDENTIFIER "org.aswf.Imath"
130-
MACOSX_FRAMEWORK_BUNDLE_VERSION "${IMATH_VERSION}"
131-
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}"
132-
MACOSX_RPATH TRUE
133-
RESOURCE "${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfig.cmake;${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfigVersion.cmake"
134-
)
138+
139+
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
140+
# Don't set FRAMEWORK_VERSION for iOS
141+
set_target_properties(${IMATH_LIBRARY} PROPERTIES
142+
FRAMEWORK TRUE
143+
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.aswf.Imath"
144+
MACOSX_FRAMEWORK_IDENTIFIER "org.aswf.Imath"
145+
MACOSX_FRAMEWORK_BUNDLE_VERSION "${IMATH_VERSION}"
146+
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}"
147+
MACOSX_RPATH TRUE
148+
RESOURCE "${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfig.cmake;${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfigVersion.cmake"
149+
)
150+
else()
151+
set_target_properties(${IMATH_LIBRARY} PROPERTIES
152+
FRAMEWORK TRUE
153+
FRAMEWORK_VERSION "${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}"
154+
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.aswf.Imath"
155+
MACOSX_FRAMEWORK_IDENTIFIER "org.aswf.Imath"
156+
MACOSX_FRAMEWORK_BUNDLE_VERSION "${IMATH_VERSION}"
157+
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}"
158+
MACOSX_RPATH TRUE
159+
RESOURCE "${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfig.cmake;${IMATH_CMAKE_CONFIG_BUILD_DIR}/ImathConfigVersion.cmake"
160+
)
161+
endif()
135162
else()
136163
set_target_properties(${IMATH_LIBRARY} PROPERTIES OUTPUT_NAME "Imath${IMATH_LIB_SUFFIX}" )
137164
endif()
@@ -142,6 +169,20 @@ endif()
142169

143170
if (IMATH_INSTALL)
144171

172+
if(APPLE AND IMATH_BUILD_APPLE_FRAMEWORK)
173+
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
174+
set(cmake_destination Imath.framework/Resources/CMake/Imath)
175+
else()
176+
set(cmake_destination Imath.framework/Versions/${Imath_VERSION_MAJOR}.${Imath_VERSION_MINOR}/Resources/CMake/Imath)
177+
endif()
178+
set(includes_destination Imath.framework/Headers)
179+
set(public_header_destination Imath.framework/Headers)
180+
else()
181+
set(cmake_destination ${CMAKE_INSTALL_LIBDIR}/cmake/Imath)
182+
set(includes_destination ${CMAKE_INSTALL_INCLUDEDIR})
183+
set(public_header_destination ${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR})
184+
endif()
185+
145186
install(TARGETS ${IMATH_LIBRARY}
146187
EXPORT Imath
147188
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -150,8 +191,15 @@ if (IMATH_INSTALL)
150191
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
151192
COMPONENT runtime
152193
OPTIONAL
153-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
154-
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR}
194+
INCLUDES DESTINATION ${includes_destination}
195+
PUBLIC_HEADER DESTINATION ${includes_destination}
196+
)
197+
198+
install(EXPORT Imath
199+
DESTINATION ${cmake_destination}
200+
FILE ImathTargets.cmake
201+
NAMESPACE Imath::
202+
EXPORT_LINK_INTERFACE_LIBRARIES
155203
)
156204

157205
if(BUILD_SHARED_LIBS

0 commit comments

Comments
 (0)