Skip to content

Commit 9f266d7

Browse files
authored
Merge pull request #171 from palemieux/add-export
Add support for find_package() and clean-up TIFF support
2 parents 02f3aa2 + 30603e5 commit 9f266d7

File tree

6 files changed

+62
-51
lines changed

6 files changed

+62
-51
lines changed

CMakeLists.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,10 @@ endif()
148148
################################################################################################
149149

150150
include(GNUInstallDirs)
151-
install(TARGETS openjph
152-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
153-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
154-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
155151

156-
install(DIRECTORY src/core/common/
157-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openjph
158-
FILES_MATCHING
159-
PATTERN "*.h")
152+
install(EXPORT openjph-config
153+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
154+
)
160155

161156
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
162157
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
@@ -179,6 +174,16 @@ configure_file(
179174
@ONLY
180175
)
181176

177+
include(CMakePackageConfigHelpers)
178+
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/openjph-configVersion.cmake
179+
COMPATIBILITY SameMinorVersion)
180+
181+
install(
182+
FILES ${CMAKE_CURRENT_BINARY_DIR}/openjph-configVersion.cmake
183+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
184+
)
185+
186+
182187
################################################################################################
183188
# Testing (OJPH_BUILD_TESTS)
184189
################################################################################################

src/apps/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ if( OJPH_ENABLE_TIFF_SUPPORT )
77

88
if( TIFF_FOUND )
99
set(USE_TIFF TRUE CACHE BOOL "Add TIFF support")
10-
include_directories( ${TIFF_INCLUDE_DIR} )
1110
add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT)
12-
elseif(MSVC)
13-
message(STATUS "TIFF support has been enabled by no path to the TIFF library "
11+
else()
12+
message(WARNING "TIFF support has been requested but no path to the TIFF library "
1413
"has been specified; please configure with -DCMAKE_PREFIX_PATH=<TIFF library directory>, "
1514
"or disable TIFF support using -DOJPH_ENABLE_TIFF_SUPPORT=OFF.")
1615
endif( TIFF_FOUND )

src/apps/ojph_compress/CMakeLists.txt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
## building ojph_compress
22
#########################
33

4-
include_directories(../common)
5-
include_directories(../../core/common)
6-
74
file(GLOB OJPH_COMPRESS "ojph_compress.cpp")
85
file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp")
96
file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp")
@@ -19,15 +16,12 @@ source_group("common" FILES ${OJPH_IMG_IO_H})
1916
if(EMSCRIPTEN)
2017
add_compile_options(-std=c++11 -O3 -fexceptions)
2118
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
22-
add_executable(ojph_compress ${SOURCES})
2319
add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
2420
target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2521
source_group("others" FILES ${OJPH_IMG_IO_SSE4})
26-
27-
target_link_libraries(ojph_compress PRIVATE openjph)
28-
install(TARGETS ojph_compress DESTINATION bin)
22+
target_include_directories(ojph_compress_simd PRIVATE ../common)
2923
target_link_libraries(ojph_compress_simd PRIVATE openjphsimd)
30-
install(TARGETS ojph_compress_simd DESTINATION bin)
24+
install(TARGETS ojph_compress_simd)
3125
else()
3226
if (NOT OJPH_DISABLE_SIMD)
3327
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -48,18 +42,21 @@ else()
4842
set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2)
4943
endif()
5044
elseif ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_ARM")
51-
45+
5246
endif()
5347

5448
endif()
5549

56-
add_executable(ojph_compress ${SOURCES})
57-
58-
if( USE_TIFF )
59-
target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES})
60-
else()
61-
target_link_libraries(ojph_compress PUBLIC openjph)
62-
endif()
50+
endif()
6351

64-
install(TARGETS ojph_compress DESTINATION bin)
52+
add_executable(ojph_compress ${SOURCES})
53+
target_include_directories(ojph_compress PRIVATE ../common)
54+
if (TIFF_FOUND AND (NOT EMSCRIPTEN))
55+
target_link_libraries(ojph_compress PRIVATE openjph TIFF::TIFF)
56+
else()
57+
target_link_libraries(ojph_compress PRIVATE openjph)
6558
endif()
59+
60+
install(TARGETS ojph_compress
61+
EXPORT openjph-config
62+
)

src/apps/ojph_expand/CMakeLists.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## building ojph_expand
22
#######################
33

4-
include_directories(../common)
5-
include_directories(../../core/common)
64

75
file(GLOB OJPH_EXPAND "ojph_expand.cpp")
86
file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp")
@@ -19,15 +17,16 @@ source_group("common" FILES ${OJPH_IMG_IO_H})
1917
if(EMSCRIPTEN)
2018
add_compile_options(-std=c++11 -O3 -fexceptions)
2119
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
22-
add_executable(ojph_expand ${SOURCES})
2320
add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
2421
target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2522
source_group("others" FILES ${OJPH_IMG_IO_SSE4})
26-
27-
target_link_libraries(ojph_expand PRIVATE openjph)
28-
install(TARGETS ojph_expand DESTINATION bin)
29-
target_link_libraries(ojph_expand_simd PRIVATE openjphsimd)
30-
install(TARGETS ojph_expand_simd DESTINATION bin)
23+
target_include_directories(ojph_expand_simd PRIVATE ../common)
24+
if (TIFF_FOUND)
25+
target_link_libraries(ojph_expand_simd PRIVATE openjphsimd TIFF::TIFF)
26+
else()
27+
target_link_libraries(ojph_expand_simd PRIVATE openjphsimd)
28+
endif()
29+
install(TARGETS ojph_expand_simd)
3130
else()
3231
if (NOT OJPH_DISABLE_SIMD)
3332
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -54,12 +53,15 @@ else()
5453
endif()
5554

5655
add_executable(ojph_expand ${SOURCES})
57-
58-
if( USE_TIFF )
59-
target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES})
56+
target_include_directories(ojph_expand PRIVATE ../common)
57+
if (TIFF_FOUND AND (NOT EMSCRIPTEN))
58+
target_link_libraries(ojph_expand PRIVATE openjph TIFF::TIFF )
6059
else()
61-
target_link_libraries(ojph_expand PUBLIC openjph)
60+
target_link_libraries(ojph_expand PRIVATE openjph)
6261
endif()
6362

64-
install(TARGETS ojph_expand DESTINATION bin)
63+
install(TARGETS ojph_expand
64+
EXPORT openjph-config
65+
)
66+
6567
endif()

src/apps/ojph_stream_expand/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
if (OJPH_BUILD_STREAM_EXPAND)
55

6-
include_directories(../common)
7-
include_directories(../../core/common)
86
set(CMAKE_CXX_STANDARD 14)
9-
7+
108
file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h")
119
file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp")
1210
file(GLOB OJPH_SOCKETS_H "../common/ojph_sockets.h")
@@ -20,12 +18,15 @@ if (OJPH_BUILD_STREAM_EXPAND)
2018
source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H})
2119

2220
add_executable(ojph_stream_expand ${SOURCES})
21+
target_include_directories(ojph_stream_expand PRIVATE ../common)
2322
if(MSVC)
2423
target_link_libraries(ojph_stream_expand PUBLIC openjph ws2_32)
2524
else()
2625
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
2726
endif(MSVC)
2827

29-
install(TARGETS ojph_stream_expand DESTINATION bin)
28+
install(TARGETS ojph_stream_expand
29+
EXPORT openjph-config
30+
)
3031

3132
endif(OJPH_BUILD_STREAM_EXPAND)

src/core/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
include_directories(common)
3-
42
file(GLOB CODESTREAM "codestream/*.cpp" "codestream/*.h")
53
file(GLOB CODESTREAM_SSE "codestream/*_sse.cpp")
64
file(GLOB CODESTREAM_SSE2 "codestream/*_sse2.cpp")
@@ -38,11 +36,10 @@ if(EMSCRIPTEN)
3836
add_library(openjph ${SOURCES})
3937
add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
4038

41-
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include>)
42-
target_include_directories(openjphsimd PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include>)
43-
4439
target_compile_options(openjphsimd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128)
4540

41+
target_include_directories(openjphsimd PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include/openjph>)
42+
4643
source_group("codestream" FILES ${CODESTREAM_WASM})
4744
source_group("coding" FILES ${CODING_WASM})
4845
source_group("transform" FILES ${TRANSFORM_WASM})
@@ -124,8 +121,8 @@ if (BUILD_SHARED_LIBS AND WIN32)
124121
endif()
125122

126123
## include library version/name
127-
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include>)
128124
target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64)
125+
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include/openjph>)
129126

130127
if (MSVC)
131128
set(OJPH_LIB_NAME_STRING "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}")
@@ -139,3 +136,13 @@ else()
139136
SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}"
140137
VERSION "${OPENJPH_VERSION}")
141138
endif()
139+
140+
install(TARGETS openjph
141+
EXPORT openjph-config
142+
)
143+
144+
install(DIRECTORY common/
145+
DESTINATION include/openjph
146+
FILES_MATCHING
147+
PATTERN "*.h"
148+
)

0 commit comments

Comments
 (0)