Skip to content

Commit 1368ddf

Browse files
authored
Merge pull request #173 from palemieux/add-export
Add support for find_package(), clean-up EMCC support and clean-up TIFF support
2 parents 02f3aa2 + fa087e7 commit 1368ddf

File tree

7 files changed

+99
-90
lines changed

7 files changed

+99
-90
lines changed

.github/workflows/emcc.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build with EMCC
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, reopened]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Configure emcc
17+
uses: mymindstorm/setup-emsdk@v14
18+
with:
19+
actions-cache-folder: 'emsdk-cache'
20+
21+
- name: Build
22+
run: |
23+
cd build
24+
cmake ..
25+
make

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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11

22
# Add tiff library
33
############################################################
4-
if( OJPH_ENABLE_TIFF_SUPPORT )
4+
if( OJPH_ENABLE_TIFF_SUPPORT AND (NOT EMSCRIPTEN))
55

66
FIND_PACKAGE( TIFF )
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 )
1716

1817
endif()
1918
############################################################
2019

20+
if (EMSCRIPTEN)
21+
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
22+
add_compile_options(-DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1 -std=c++11 -O3 -fexceptions)
23+
endif()
24+
2125
## Build executables
2226
add_subdirectory(ojph_expand)
2327
add_subdirectory(ojph_compress)
24-
add_subdirectory(ojph_stream_expand)
28+
if (OJPH_BUILD_STREAM_EXPAND)
29+
add_subdirectory(ojph_stream_expand)
30+
endif()
Lines changed: 8 additions & 22 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")
@@ -17,17 +14,7 @@ source_group("others" FILES ${OJPH_IMG_IO})
1714
source_group("common" FILES ${OJPH_IMG_IO_H})
1815

1916
if(EMSCRIPTEN)
20-
add_compile_options(-std=c++11 -O3 -fexceptions)
21-
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})
23-
add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
24-
target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2517
source_group("others" FILES ${OJPH_IMG_IO_SSE4})
26-
27-
target_link_libraries(ojph_compress PRIVATE openjph)
28-
install(TARGETS ojph_compress DESTINATION bin)
29-
target_link_libraries(ojph_compress_simd PRIVATE openjphsimd)
30-
install(TARGETS ojph_compress_simd DESTINATION bin)
3118
else()
3219
if (NOT OJPH_DISABLE_SIMD)
3320
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -48,18 +35,17 @@ else()
4835
set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2)
4936
endif()
5037
elseif ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_ARM")
51-
38+
5239
endif()
5340

5441
endif()
5542

56-
add_executable(ojph_compress ${SOURCES})
43+
endif()
5744

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()
45+
add_executable(ojph_compress ${SOURCES})
46+
target_include_directories(ojph_compress PRIVATE ../common)
47+
target_link_libraries(ojph_compress PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
6348

64-
install(TARGETS ojph_compress DESTINATION bin)
65-
endif()
49+
install(TARGETS ojph_compress
50+
EXPORT openjph-config
51+
)

src/apps/ojph_expand/CMakeLists.txt

Lines changed: 7 additions & 20 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")
@@ -17,17 +15,7 @@ source_group("others" FILES ${OJPH_IMG_IO})
1715
source_group("common" FILES ${OJPH_IMG_IO_H})
1816

1917
if(EMSCRIPTEN)
20-
add_compile_options(-std=c++11 -O3 -fexceptions)
21-
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})
23-
add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
24-
target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2518
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)
3119
else()
3220
if (NOT OJPH_DISABLE_SIMD)
3321
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -53,13 +41,12 @@ else()
5341

5442
endif()
5543

56-
add_executable(ojph_expand ${SOURCES})
44+
endif()
5745

58-
if( USE_TIFF )
59-
target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES})
60-
else()
61-
target_link_libraries(ojph_expand PUBLIC openjph)
62-
endif()
46+
add_executable(ojph_expand ${SOURCES})
47+
target_include_directories(ojph_expand PRIVATE ../common)
48+
target_link_libraries(ojph_expand PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
6349

64-
install(TARGETS ojph_expand DESTINATION bin)
65-
endif()
50+
install(TARGETS ojph_expand
51+
EXPORT openjph-config
52+
)
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
## building ojph_stream_expand
22
##############################
33

4-
if (OJPH_BUILD_STREAM_EXPAND)
4+
set(CMAKE_CXX_STANDARD 14)
55

6-
include_directories(../common)
7-
include_directories(../../core/common)
8-
set(CMAKE_CXX_STANDARD 14)
9-
10-
file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h")
11-
file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp")
12-
file(GLOB OJPH_SOCKETS_H "../common/ojph_sockets.h")
13-
file(GLOB OJPH_THREADS "../others/ojph_threads.cpp")
14-
file(GLOB OJPH_THREADS_H "../common/ojph_threads.h")
6+
file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h")
7+
file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp")
8+
file(GLOB OJPH_SOCKETS_H "../common/ojph_sockets.h")
9+
file(GLOB OJPH_THREADS "../others/ojph_threads.cpp")
10+
file(GLOB OJPH_THREADS_H "../common/ojph_threads.h")
1511

16-
list(APPEND SOURCES ${OJPH_STREAM_EXPAND} ${OJPH_SOCKETS} ${OJPH_SOCKETS_H} ${OJPH_THREADS} ${OJPH_THREADS_H})
12+
list(APPEND SOURCES ${OJPH_STREAM_EXPAND} ${OJPH_SOCKETS} ${OJPH_SOCKETS_H} ${OJPH_THREADS} ${OJPH_THREADS_H})
1713

18-
source_group("main" FILES ${OJPH_STREAM_EXPAND})
19-
source_group("others" FILES ${OJPH_SOCKETS} ${OJPH_THREADS})
20-
source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H})
14+
source_group("main" FILES ${OJPH_STREAM_EXPAND})
15+
source_group("others" FILES ${OJPH_SOCKETS} ${OJPH_THREADS})
16+
source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H})
2117

22-
add_executable(ojph_stream_expand ${SOURCES})
23-
if(MSVC)
24-
target_link_libraries(ojph_stream_expand PUBLIC openjph ws2_32)
25-
else()
26-
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
27-
endif(MSVC)
18+
add_executable(ojph_stream_expand ${SOURCES})
19+
target_include_directories(ojph_stream_expand PRIVATE ../common)
20+
if(MSVC)
21+
target_link_libraries(ojph_stream_expand PUBLIC openjph ws2_32)
22+
else()
23+
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
24+
endif(MSVC)
2825

29-
install(TARGETS ojph_stream_expand DESTINATION bin)
30-
31-
endif(OJPH_BUILD_STREAM_EXPAND)
26+
install(TARGETS ojph_stream_expand
27+
EXPORT openjph-config
28+
)

src/core/CMakeLists.txt

Lines changed: 15 additions & 12 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")
@@ -34,14 +32,8 @@ source_group("others" FILES ${OTHERS})
3432
source_group("transform" FILES ${TRANSFORM})
3533

3634
if(EMSCRIPTEN)
37-
add_compile_options(-std=c++11 -O3 -fexceptions)
38-
add_library(openjph ${SOURCES})
39-
add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
40-
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-
44-
target_compile_options(openjphsimd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128)
35+
add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_ENABLE_WASM_SIMD -msimd128)
36+
list(APPEND SOURCES ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
4537

4638
source_group("codestream" FILES ${CODESTREAM_WASM})
4739
source_group("coding" FILES ${CODING_WASM})
@@ -114,18 +106,19 @@ else()
114106

115107
endif()
116108

117-
add_library(openjph ${SOURCES})
118109

119110
endif()
120111

112+
add_library(openjph ${SOURCES})
113+
121114
## The option BUILD_SHARED_LIBS
122115
if (BUILD_SHARED_LIBS AND WIN32)
123116
target_compile_definitions(openjph PRIVATE OJPH_BUILD_SHARED_LIBRARY)
124117
endif()
125118

126119
## include library version/name
127-
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include>)
128120
target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64)
121+
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include/openjph>)
129122

130123
if (MSVC)
131124
set(OJPH_LIB_NAME_STRING "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}")
@@ -139,3 +132,13 @@ else()
139132
SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}"
140133
VERSION "${OPENJPH_VERSION}")
141134
endif()
135+
136+
install(TARGETS openjph
137+
EXPORT openjph-config
138+
)
139+
140+
install(DIRECTORY common/
141+
DESTINATION include/openjph
142+
FILES_MATCHING
143+
PATTERN "*.h"
144+
)

0 commit comments

Comments
 (0)