Skip to content

Commit 3181392

Browse files
authored
Merge pull request aous72#182 from kmilos/cmake-config
CMake: polish export config
2 parents 967863d + d38c3e3 commit 3181392

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

CMakeLists.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,24 @@ endif()
165165

166166
include(GNUInstallDirs)
167167

168-
install(EXPORT openjph-config
168+
install(EXPORT openjph-targets
169169
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
170170
)
171171

172-
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
173-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
172+
include(CMakePackageConfigHelpers)
173+
174+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/src/openjph-config.cmake.in
175+
"${CMAKE_CURRENT_BINARY_DIR}/openjph-config.cmake"
176+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
177+
)
178+
179+
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake
180+
COMPATIBILITY SameMinorVersion)
181+
182+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openjph-config.cmake
183+
${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake
184+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
185+
)
174186

175187
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
176188
set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
@@ -185,21 +197,15 @@ else()
185197
endif()
186198

187199
configure_file(
188-
"${CMAKE_CURRENT_SOURCE_DIR}/src/pkg-config.pc.cmake"
200+
"${CMAKE_CURRENT_SOURCE_DIR}/src/openjph.pc.in"
189201
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
190202
@ONLY
191203
)
192204

193-
include(CMakePackageConfigHelpers)
194-
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake
195-
COMPATIBILITY SameMinorVersion)
196-
197-
install(
198-
FILES ${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake
199-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
205+
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
206+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
200207
)
201208

202-
203209
################################################################################################
204210
# Testing (OJPH_BUILD_TESTS)
205211
################################################################################################
@@ -208,4 +214,3 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND OJPH_BUILD_TESTS)
208214
enable_testing()
209215
add_subdirectory(tests)
210216
endif()
211-

src/apps/ojph_compress/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ add_executable(ojph_compress ${SOURCES})
5050
target_include_directories(ojph_compress PRIVATE ../common)
5151
target_link_libraries(ojph_compress PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
5252

53-
install(TARGETS ojph_compress
54-
EXPORT openjph-config
55-
)
53+
install(TARGETS ojph_compress)

src/apps/ojph_expand/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ add_executable(ojph_expand ${SOURCES})
5050
target_include_directories(ojph_expand PRIVATE ../common)
5151
target_link_libraries(ojph_expand PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
5252

53-
install(TARGETS ojph_expand
54-
EXPORT openjph-config
55-
)
53+
install(TARGETS ojph_expand)

src/apps/ojph_stream_expand/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ else()
2323
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
2424
endif(MSVC)
2525

26-
install(TARGETS ojph_stream_expand
27-
EXPORT openjph-config
28-
)
26+
install(TARGETS ojph_stream_expand)

src/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ else()
139139
endif()
140140

141141
install(TARGETS openjph
142-
EXPORT openjph-config
142+
EXPORT openjph-targets
143143
)
144144

145145
install(DIRECTORY common/

src/openjph-config.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/openjph-targets.cmake")
4+
5+
check_required_components(openjph)
File renamed without changes.

0 commit comments

Comments
 (0)