Skip to content

Commit b683d40

Browse files
committed
Clean-up EMCC
Add EMCC CI
1 parent 30603e5 commit b683d40

File tree

6 files changed

+72
-73
lines changed

6 files changed

+72
-73
lines changed

.github/workflows/emcc.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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
26+
cmake --install .

src/apps/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

@@ -17,7 +17,14 @@ if( OJPH_ENABLE_TIFF_SUPPORT )
1717
endif()
1818
############################################################
1919

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+
2025
## Build executables
2126
add_subdirectory(ojph_expand)
2227
add_subdirectory(ojph_compress)
23-
add_subdirectory(ojph_stream_expand)
28+
if (OJPH_BUILD_STREAM_EXPAND)
29+
add_subdirectory(ojph_stream_expand)
30+
endif()

src/apps/ojph_compress/CMakeLists.txt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ source_group("others" FILES ${OJPH_IMG_IO})
1414
source_group("common" FILES ${OJPH_IMG_IO_H})
1515

1616
if(EMSCRIPTEN)
17-
add_compile_options(-std=c++11 -O3 -fexceptions)
18-
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
19-
add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
20-
target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2117
source_group("others" FILES ${OJPH_IMG_IO_SSE4})
22-
target_include_directories(ojph_compress_simd PRIVATE ../common)
23-
target_link_libraries(ojph_compress_simd PRIVATE openjphsimd)
24-
install(TARGETS ojph_compress_simd)
2518
else()
2619
if (NOT OJPH_DISABLE_SIMD)
2720
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -51,11 +44,7 @@ endif()
5144

5245
add_executable(ojph_compress ${SOURCES})
5346
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)
58-
endif()
47+
target_link_libraries(ojph_compress PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
5948

6049
install(TARGETS ojph_compress
6150
EXPORT openjph-config

src/apps/ojph_expand/CMakeLists.txt

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@ source_group("others" FILES ${OJPH_IMG_IO})
1515
source_group("common" FILES ${OJPH_IMG_IO_H})
1616

1717
if(EMSCRIPTEN)
18-
add_compile_options(-std=c++11 -O3 -fexceptions)
19-
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
20-
add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
21-
target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
2218
source_group("others" FILES ${OJPH_IMG_IO_SSE4})
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)
3019
else()
3120
if (NOT OJPH_DISABLE_SIMD)
3221
if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_X86_64") OR ("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_I386"))
@@ -52,16 +41,12 @@ else()
5241

5342
endif()
5443

55-
add_executable(ojph_expand ${SOURCES})
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 )
59-
else()
60-
target_link_libraries(ojph_expand PRIVATE openjph)
61-
endif()
44+
endif()
6245

63-
install(TARGETS ojph_expand
64-
EXPORT openjph-config
65-
)
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>)
6649

67-
endif()
50+
install(TARGETS ojph_expand
51+
EXPORT openjph-config
52+
)
Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
## building ojph_stream_expand
22
##############################
33

4-
if (OJPH_BUILD_STREAM_EXPAND)
5-
6-
set(CMAKE_CXX_STANDARD 14)
7-
8-
file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h")
9-
file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp")
10-
file(GLOB OJPH_SOCKETS_H "../common/ojph_sockets.h")
11-
file(GLOB OJPH_THREADS "../others/ojph_threads.cpp")
12-
file(GLOB OJPH_THREADS_H "../common/ojph_threads.h")
13-
14-
list(APPEND SOURCES ${OJPH_STREAM_EXPAND} ${OJPH_SOCKETS} ${OJPH_SOCKETS_H} ${OJPH_THREADS} ${OJPH_THREADS_H})
15-
16-
source_group("main" FILES ${OJPH_STREAM_EXPAND})
17-
source_group("others" FILES ${OJPH_SOCKETS} ${OJPH_THREADS})
18-
source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H})
19-
20-
add_executable(ojph_stream_expand ${SOURCES})
21-
target_include_directories(ojph_stream_expand PRIVATE ../common)
22-
if(MSVC)
23-
target_link_libraries(ojph_stream_expand PUBLIC openjph ws2_32)
24-
else()
25-
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
26-
endif(MSVC)
27-
28-
install(TARGETS ojph_stream_expand
29-
EXPORT openjph-config
30-
)
31-
32-
endif(OJPH_BUILD_STREAM_EXPAND)
4+
set(CMAKE_CXX_STANDARD 14)
5+
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")
11+
12+
list(APPEND SOURCES ${OJPH_STREAM_EXPAND} ${OJPH_SOCKETS} ${OJPH_SOCKETS_H} ${OJPH_THREADS} ${OJPH_THREADS_H})
13+
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})
17+
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)
25+
26+
install(TARGETS ojph_stream_expand
27+
EXPORT openjph-config
28+
)

src/core/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ source_group("others" FILES ${OTHERS})
3232
source_group("transform" FILES ${TRANSFORM})
3333

3434
if(EMSCRIPTEN)
35-
add_compile_options(-std=c++11 -O3 -fexceptions)
36-
add_library(openjph ${SOURCES})
37-
add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
38-
39-
target_compile_options(openjphsimd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128)
40-
41-
target_include_directories(openjphsimd PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include/openjph>)
35+
add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_ENABLE_WASM_SIMD -msimd128)
36+
list(APPEND SOURCES ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
4237

4338
source_group("codestream" FILES ${CODESTREAM_WASM})
4439
source_group("coding" FILES ${CODING_WASM})
@@ -111,10 +106,11 @@ else()
111106

112107
endif()
113108

114-
add_library(openjph ${SOURCES})
115109

116110
endif()
117111

112+
add_library(openjph ${SOURCES})
113+
118114
## The option BUILD_SHARED_LIBS
119115
if (BUILD_SHARED_LIBS AND WIN32)
120116
target_compile_definitions(openjph PRIVATE OJPH_BUILD_SHARED_LIBRARY)

0 commit comments

Comments
 (0)