From f2c25c0c9a31b36d49a497bc2bbeea5085ff5c8c Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Fri, 24 Nov 2023 12:49:26 +1100 Subject: [PATCH 01/13] Test can run in Debug build on windows. --- tests/CMakeLists.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index abcc7ede..b597c265 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -43,8 +43,15 @@ include(GoogleTest) gtest_add_tests(TARGET test_executables) if (WIN32) - add_custom_command(TARGET test_executables POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest.dll" "./Release/" - COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest_main.dll" "./Release/" - ) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_custom_command(TARGET test_executables POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "../bin/Debug/gtest.dll" "./Debug/" + COMMAND ${CMAKE_COMMAND} -E copy "../bin/Debug/gtest_main.dll" "./Debug/" + ) + elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + add_custom_command(TARGET test_executables POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest.dll" "./Release/" + COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest_main.dll" "./Release/" + ) + endif() endif() From 7a8415e5ebb5cb94c2f321a00c7ccc79659e835b Mon Sep 17 00:00:00 2001 From: aous72 Date: Mon, 18 Dec 2023 16:38:51 +1100 Subject: [PATCH 02/13] Minor improvement to CMakeLists.txt --- .gitignore | 1 + CMakeLists.txt | 56 +++++++++++++++------------------------------- ojph_libname.cmake | 37 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 ojph_libname.cmake diff --git a/.gitignore b/.gitignore index 627f2909..c101eb7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store mytest/* others/* +lib/* .vscode build.sh \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index dbdeff43..910f9b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,14 @@ cmake_minimum_required(VERSION 3.11.0) +## project project (openjph DESCRIPTION "Open source implementation of JPH" LANGUAGES CXX) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) ################################################################################################ # Building OpenJPH ################################################################################################ -############################################################ -# Parse version file -# credit: https://stackoverflow.com/a/47084079 - -file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/core/common/ojph_version.h" VERFILE) -if (NOT VERFILE) - message(FATAL_ERROR "Failed to parse ojph_version.h!") -endif() - -string(REGEX MATCH "OPENJPH_VERSION_MAJOR ([0-9]*)" _ ${VERFILE}) -set(OPENJPH_VERSION_MAJOR ${CMAKE_MATCH_1}) -string(REGEX MATCH "OPENJPH_VERSION_MINOR ([0-9]*)" _ ${VERFILE}) -set(OPENJPH_VERSION_MINOR ${CMAKE_MATCH_1}) -string(REGEX MATCH "OPENJPH_VERSION_PATCH ([a-z0-9]*)" _ ${VERFILE}) -set(OPENJPH_VERSION_PATCH ${CMAKE_MATCH_1}) - -set(OPENJPH_VERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}.${OPENJPH_VERSION_PATCH}") -############################################################ - +## options option(OJPH_DISABLE_INTEL_SIMD "Disables the use of SIMD instructions and associated files" OFF) option(OJPH_ENABLE_INTEL_AVX512 "enables the use of AVX512 SIMD instructions and associated files" ON) option(BUILD_SHARED_LIBS "Shared Libraries" ON) @@ -45,6 +29,7 @@ set(CMAKE_CXX_FLAGS_ASAN CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds." FORCE) + ## build type if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message( STATUS "To use AddressSanitizer, use \"cmake .. -DCMAKE_BUILD_TYPE=asan\"" ) @@ -85,6 +70,13 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) include_directories(src/core/common) include_directories(src/apps/common) @@ -150,25 +142,13 @@ else() add_library(openjph ${SOURCES}) endif() +## include library version/name +include(ojph_libname.cmake) + target_include_directories(openjph PUBLIC src/core/common) target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) -if (OPENJPH_VERSION) - if (WIN32) - set_target_properties(openjph - PROPERTIES - OUTPUT_NAME "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") - else() - set_target_properties(openjph - PROPERTIES - SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}" - VERSION "${OPENJPH_VERSION}") - endif() -else() - message(FATAL_ERROR "OPENJPH_VERSION is not set") -endif() - if (MSVC) set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") @@ -238,7 +218,7 @@ endif() if(OJPH_BUILD_EXECUTABLES) add_executable(ojph_expand ${OJPH_EXPAND}) - add_executable(ojph_compress ${OJPH_COMPRESS}) + add_executable(ojph_compress ${OJPH_COMPRESS}) endif() if (MSVC) @@ -264,11 +244,11 @@ endif() ################################################################################################ if(OJPH_BUILD_EXECUTABLES) - install(TARGETS ojph_expand + install(TARGETS ojph_expand DESTINATION bin) - install(TARGETS ojph_compress - DESTINATION bin) + install(TARGETS ojph_compress + DESTINATION bin) endif() include(GNUInstallDirs) diff --git a/ojph_libname.cmake b/ojph_libname.cmake new file mode 100644 index 00000000..8fc999af --- /dev/null +++ b/ojph_libname.cmake @@ -0,0 +1,37 @@ +################################################################################################ +# Generating library name +################################################################################################ + +############################################################ +# Parse version file +# credit: https://stackoverflow.com/a/47084079 + +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/core/common/ojph_version.h" VERFILE) +if (NOT VERFILE) + message(FATAL_ERROR "Failed to parse ojph_version.h!") +endif() + +string(REGEX MATCH "OPENJPH_VERSION_MAJOR ([0-9]*)" _ ${VERFILE}) +set(OPENJPH_VERSION_MAJOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "OPENJPH_VERSION_MINOR ([0-9]*)" _ ${VERFILE}) +set(OPENJPH_VERSION_MINOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "OPENJPH_VERSION_PATCH ([a-z0-9]*)" _ ${VERFILE}) +set(OPENJPH_VERSION_PATCH ${CMAKE_MATCH_1}) + +set(OPENJPH_VERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}.${OPENJPH_VERSION_PATCH}") +############################################################ + +if (OPENJPH_VERSION) + if (WIN32) + set_target_properties(openjph + PROPERTIES + OUTPUT_NAME "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") + else() + set_target_properties(openjph + PROPERTIES + SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}" + VERSION "${OPENJPH_VERSION}") + endif() +else() + message(FATAL_ERROR "OPENJPH_VERSION is not set") +endif() From 16a82095baee7a9dc247a41fe96f8e72debfdb3d Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Wed, 27 Dec 2023 14:10:57 +1100 Subject: [PATCH 03/13] Removed unneeded file --- CMakeLists.txt | 14 +++++++------- tests/test.py | 15 --------------- 2 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 tests/test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 910f9b44..00bff012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,13 +70,13 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) include_directories(src/core/common) include_directories(src/apps/common) diff --git a/tests/test.py b/tests/test.py deleted file mode 100644 index fb8c0df9..00000000 --- a/tests/test.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/python3 - -import numpy as np -import cv2 -import matplotlib.pyplot as plt - -# import os -# os.system('') -# subprocess.run - -print('Testing in Python') - -im = cv2.imread("../../ARRI_AlexaDrums_3840x2160p_24_12b_P3_444_00000.ppm", cv2.IMREAD_UNCHANGED ); -hist, bin_edges = np.histogram(im.astype('int32'), bins=range(4096)); -_ = plt.hist(hist, bin_edges); From 91724a84c482e86396b32f21ac9a40369e9e098e Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Wed, 27 Dec 2023 20:24:16 +1100 Subject: [PATCH 04/13] Re-arranging CMake files. --- CMakeLists.txt | 216 +++----------------------- ojph_libname.cmake | 12 +- src/apps/CMakeLists.txt | 51 ++++++ src/apps/ojph_compress/CMakeLists.txt | 38 +++++ src/apps/ojph_expand/CMakeLists.txt | 38 +++++ src/core/CMakeLists.txt | 106 +++++++++++++ tests/CMakeLists.txt | 4 +- tests/mse_pae.cmake | 22 +-- tests/mse_pae.cpp | 4 +- tests/test_executables.cpp | 4 +- 10 files changed, 277 insertions(+), 218 deletions(-) create mode 100644 src/apps/CMakeLists.txt create mode 100644 src/apps/ojph_compress/CMakeLists.txt create mode 100644 src/apps/ojph_expand/CMakeLists.txt create mode 100644 src/core/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 00bff012..3cf131cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,13 @@ option(OJPH_ENABLE_TIFF_SUPPORT "Enables input and output support for TIFF files option(OJPH_BUILD_TESTS "Enables building test code" OFF) option(OJPH_BUILD_EXECUTABLES "Enables building command line executables" ON) +## Setting some of the options if EMSCRIPTEN is the compiler +if(EMSCRIPTEN) + set(OJPH_DISABLE_INTEL_SIMD ON) + set(BUILD_SHARED_LIBS OFF) + set(OJPH_ENABLE_TIFF_SUPPORT OFF) +endif() + # This is related to how the timestamp is set for URL downloaded files. # Set DOWNLOAD_EXTRACT_TIMESTAMP if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") @@ -29,13 +36,17 @@ set(CMAKE_CXX_FLAGS_ASAN CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds." FORCE) - ## build type +## build type if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message( STATUS "To use AddressSanitizer, use \"cmake .. -DCMAKE_BUILD_TYPE=asan\"" ) endif() message(STATUS "Building ${CMAKE_BUILD_TYPE}") +## Library name +include(ojph_libname.cmake) + +## C++ version and flags set(CMAKE_CXX_STANDARD 14) if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /D \"_CRT_SECURE_NO_WARNINGS\"") @@ -44,215 +55,38 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -Wall -Wextra -Wconversion -Wunused-parameter") endif() +## The option OJPH_DISABLE_INTEL_SIMD and OJPH_ENABLE_INTEL_AVX512 if (OJPH_DISABLE_INTEL_SIMD) if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_DISABLE_INTEL_SIMD\"") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_DISABLE_INTEL_SIMD") endif() +elseif (OJPH_ENABLE_INTEL_AVX512) + if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_INTEL_AVX512\"") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_INTEL_AVX512") + endif() endif() -if (OJPH_ENABLE_INTEL_AVX512) - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_INTEL_AVX512\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_INTEL_AVX512") - endif() -endif() - +## The option BUILD_SHARED_LIBS if (BUILD_SHARED_LIBS AND MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_BUILD_SHARED_LIBRARY\"") endif() -if (OJPH_CODE_COVERAGE AND NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") +## Build library and applications +add_subdirectory(src/core) +if (OJPH_BUILD_EXECUTABLES) + add_subdirectory(src/apps) endif() -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) - -include_directories(src/core/common) -include_directories(src/apps/common) - -file(GLOB CODESTREAM "src/core/codestream/*.cpp" "src/core/codestream/*.h") -file(GLOB CODESTREAM_SSE "src/core/codestream/*_sse.cpp") -file(GLOB CODESTREAM_SSE2 "src/core/codestream/*_sse2.cpp") -file(GLOB CODESTREAM_AVX "src/core/codestream/*_avx.cpp") -file(GLOB CODESTREAM_AVX2 "src/core/codestream/*_avx2.cpp") -file(GLOB CODESTREAM_WASM "src/core/codestream/*_wasm.cpp") -file(GLOB CODING "src/core/coding/*.cpp" "src/core/coding/*.h") -file(GLOB CODING_SSSE3 "src/core/coding/*_ssse3.cpp") -file(GLOB CODING_WASM "src/core/coding/*_wasm.cpp") -file(GLOB CODING_AVX512 "src/core/coding/*_avx512.cpp") -file(GLOB COMMON "src/core/common/*.h") -file(GLOB OTHERS "src/core/others/*.cpp") -file(GLOB TRANSFORM "src/core/transform/*.cpp" "src/core/transform/*.h") -file(GLOB TRANSFORM_SSE "src/core/transform/*_sse.cpp") -file(GLOB TRANSFORM_SSE2 "src/core/transform/*_sse2.cpp") -file(GLOB TRANSFORM_AVX "src/core/transform/*_avx.cpp") -file(GLOB TRANSFORM_AVX2 "src/core/transform/*_avx2.cpp") -file(GLOB TRANSFORM_WASM "src/core/transform/*_wasm.cpp") - -list(REMOVE_ITEM CODESTREAM ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODESTREAM_WASM}) -list(REMOVE_ITEM CODING ${CODING_SSSE3} ${CODING_WASM} ${CODING_AVX512}) -list(REMOVE_ITEM TRANSFORM ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_WASM}) -list(APPEND SOURCES ${CODESTREAM} ${CODING} ${COMMON} ${OTHERS} ${TRANSFORM}) - -source_group("codestream" FILES ${CODESTREAM}) -source_group("coding" FILES ${CODING}) -source_group("common" FILES ${COMMON}) -source_group("others" FILES ${OTHERS}) -source_group("transform" FILES ${TRANSFORM}) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/src/pkg-config.pc.cmake" - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pc" -) - -if(EMSCRIPTEN) - set(OJPH_DISABLE_INTEL_SIMD ON) - set(BUILD_SHARED_LIBS OFF) - set(OJPH_ENABLE_TIFF_SUPPORT OFF) - add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) - add_library(openjph ${SOURCES}) - add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM}) - target_include_directories(openjph PUBLIC src/core/common) - target_include_directories(openjphsimd PUBLIC src/core/common) - target_compile_options(openjphsimd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128) - source_group("codestream" FILES ${CODESTREAM_WASM}) - source_group("coding" FILES ${CODING_WASM}) - source_group("transform" FILES ${TRANSFORM_WASM}) -elseif(NOT OJPH_DISABLE_INTEL_SIMD) - add_library(openjph ${SOURCES} ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODING_SSSE3} ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2}) - source_group("codestream" FILES ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2}) - source_group("coding" FILES ${CODING_SSSE3}) - source_group("transform" FILES ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2}) - if (OJPH_ENABLE_INTEL_AVX512) - target_sources(openjph PRIVATE ${CODING_AVX512}) - source_group("coding" FILES ${CODING_AVX512}) - endif() -else() - add_library(openjph ${SOURCES}) -endif() - -## include library version/name -include(ojph_libname.cmake) - -target_include_directories(openjph PUBLIC src/core/common) - -target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) - -if (MSVC) - set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") - set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512") - set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") - set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") -else() - set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) - set_source_files_properties(src/core/coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3) - set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd) - set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) - set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) -endif() - -############################################################ -if( OJPH_ENABLE_TIFF_SUPPORT ) - - if( WIN32 ) - - set(TIFF_INCLUDE_DIR "C:\\Program Files\\tiff\\include" CACHE PATH "the directory containing the TIFF headers") - set(TIFF_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") - set(TIFF_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") - set(TIFFXX_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") - set(TIFFXX_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") - - message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) - message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) - message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) - message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) - message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) - message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) - - endif( WIN32 ) - - FIND_PACKAGE( TIFF ) - - if( TIFF_FOUND ) - set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") - include_directories( ${TIFF_INCLUDE_DIR} ) - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_TIFF_SUPPORT\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_TIFF_SUPPORT") - endif() - #include_directories(${CMAKE_BINARY_DIR}/libtiff) # for tiffconf.h on windows - endif( TIFF_FOUND ) - -endif() -############################################################ - -set(OJPH_EXPAND src/apps/ojph_expand/ojph_expand.cpp src/apps/others/ojph_img_io.cpp) -set(OJPH_COMPRESS src/apps/ojph_compress/ojph_compress.cpp src/apps/others/ojph_img_io.cpp) -set(OJPH_IMG_IO_SSE41 src/apps/others/ojph_img_io_sse41.cpp) -set(OJPH_IMG_IO_AVX2 src/apps/others/ojph_img_io_avx2.cpp) - -if(NOT OJPH_DISABLE_INTEL_SIMD) - list(APPEND OJPH_EXPAND ${OJPH_IMG_IO_SSE41}) - list(APPEND OJPH_EXPAND ${OJPH_IMG_IO_AVX2}) - list(APPEND OJPH_COMPRESS ${OJPH_IMG_IO_SSE41}) - list(APPEND OJPH_COMPRESS ${OJPH_IMG_IO_AVX2}) -endif() - -if(OJPH_BUILD_EXECUTABLES) - add_executable(ojph_expand ${OJPH_EXPAND}) - add_executable(ojph_compress ${OJPH_COMPRESS}) -endif() - -if (MSVC) - set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") -else() - set_source_files_properties(src/apps/others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) -endif() - -if(OJPH_BUILD_EXECUTABLES) - if( USE_TIFF ) - target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) - target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) - else() - target_link_libraries(ojph_expand PUBLIC openjph) - target_link_libraries(ojph_compress PUBLIC openjph) - endif() -endif() - - ################################################################################################ # Install ################################################################################################ -if(OJPH_BUILD_EXECUTABLES) - install(TARGETS ojph_expand - DESTINATION bin) - - install(TARGETS ojph_compress - DESTINATION bin) -endif() - include(GNUInstallDirs) -install(TARGETS openjph LIBRARY +install(TARGETS openjph LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install (DIRECTORY src/core/common/ diff --git a/ojph_libname.cmake b/ojph_libname.cmake index 8fc999af..942a62e9 100644 --- a/ojph_libname.cmake +++ b/ojph_libname.cmake @@ -21,17 +21,9 @@ set(OPENJPH_VERSION_PATCH ${CMAKE_MATCH_1}) set(OPENJPH_VERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}.${OPENJPH_VERSION_PATCH}") ############################################################ +message(STATUS "OpenJPH library version: ${OPENJPH_VERSION}") + if (OPENJPH_VERSION) - if (WIN32) - set_target_properties(openjph - PROPERTIES - OUTPUT_NAME "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") - else() - set_target_properties(openjph - PROPERTIES - SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}" - VERSION "${OPENJPH_VERSION}") - endif() else() message(FATAL_ERROR "OPENJPH_VERSION is not set") endif() diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt new file mode 100644 index 00000000..b67a1dd5 --- /dev/null +++ b/src/apps/CMakeLists.txt @@ -0,0 +1,51 @@ +# Add tiff library +############################################################ +if( OJPH_ENABLE_TIFF_SUPPORT ) + + if( WIN32 ) + + set(TIFF_INCLUDE_DIR "C:\\Program Files\\tiff\\include" CACHE PATH "the directory containing the TIFF headers") + set(TIFF_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") + set(TIFF_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") + set(TIFFXX_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") + set(TIFFXX_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") + + message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) + message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) + message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) + message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) + message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) + message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) + + endif( WIN32 ) + + FIND_PACKAGE( TIFF ) + + if( TIFF_FOUND ) + set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") + include_directories( ${TIFF_INCLUDE_DIR} ) + if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_TIFF_SUPPORT\"") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_TIFF_SUPPORT") + endif() + #include_directories(${CMAKE_BINARY_DIR}/libtiff) # for tiffconf.h on windows + endif( TIFF_FOUND ) + +endif() +############################################################ + +## Change folders +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) + +## Build executables +add_subdirectory(ojph_expand) +add_subdirectory(ojph_compress) \ No newline at end of file diff --git a/src/apps/ojph_compress/CMakeLists.txt b/src/apps/ojph_compress/CMakeLists.txt new file mode 100644 index 00000000..24f3112c --- /dev/null +++ b/src/apps/ojph_compress/CMakeLists.txt @@ -0,0 +1,38 @@ +## building ojph_compress +######################### + +include_directories(../common) + +file(GLOB OJPH_COMPRESS "ojph_compress.cpp") +file(GLOB OJPH_IMG_IO "../others/ojph_img_io*.cpp") +file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + +if(NOT OJPH_DISABLE_INTEL_SIMD) + list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_SSE41}) + list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_AVX2}) +endif() + +source_group("main" FILES ${OJPH_COMPRESS}) +source_group("others" FILES ${OJPH_IMG_IO}) +source_group("common" FILES ${OJPH_IMG_IO_H}) + +if(OJPH_BUILD_EXECUTABLES) + add_executable(ojph_compress ${OJPH_COMPRESS} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) +endif() + +if (MSVC) + set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") +else() + set_source_files_properties(../others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) +endif() + +if(OJPH_BUILD_EXECUTABLES) + if( USE_TIFF ) + target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_compress PUBLIC openjph) + endif() +endif() + +install(TARGETS ojph_compress DESTINATION bin) \ No newline at end of file diff --git a/src/apps/ojph_expand/CMakeLists.txt b/src/apps/ojph_expand/CMakeLists.txt new file mode 100644 index 00000000..29644dfc --- /dev/null +++ b/src/apps/ojph_expand/CMakeLists.txt @@ -0,0 +1,38 @@ +## building ojph_expand +####################### + +include_directories(../common) + +file(GLOB OJPH_EXPAND "ojph_expand.cpp") +file(GLOB OJPH_IMG_IO "../others/ojph_img_io*.cpp") +file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + +if(NOT OJPH_DISABLE_INTEL_SIMD) + list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_SSE41}) + list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_AVX2}) +endif() + +source_group("main" FILES ${OJPH_EXPAND}) +source_group("others" FILES ${OJPH_IMG_IO}) +source_group("common" FILES ${OJPH_IMG_IO_H}) + +if(OJPH_BUILD_EXECUTABLES) + add_executable(ojph_expand ${OJPH_EXPAND} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) +endif() + +if (MSVC) + set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") +else() + set_source_files_properties(../others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) +endif() + +if(OJPH_BUILD_EXECUTABLES) + if( USE_TIFF ) + target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_expand PUBLIC openjph) + endif() +endif() + +install(TARGETS ojph_expand DESTINATION bin) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 00000000..dc87c5a1 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,106 @@ + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) + +include_directories(common) + +file(GLOB CODESTREAM "codestream/*.cpp" "codestream/*.h") +file(GLOB CODESTREAM_SSE "codestream/*_sse.cpp") +file(GLOB CODESTREAM_SSE2 "codestream/*_sse2.cpp") +file(GLOB CODESTREAM_AVX "codestream/*_avx.cpp") +file(GLOB CODESTREAM_AVX2 "codestream/*_avx2.cpp") +file(GLOB CODESTREAM_WASM "codestream/*_wasm.cpp") +file(GLOB CODING "coding/*.cpp" "coding/*.h") +file(GLOB CODING_SSSE3 "coding/*_ssse3.cpp") +file(GLOB CODING_WASM "coding/*_wasm.cpp") +file(GLOB CODING_AVX512 "coding/*_avx512.cpp") +file(GLOB COMMON "common/*.h") +file(GLOB OTHERS "others/*.cpp") +file(GLOB TRANSFORM "transform/*.cpp" "transform/*.h") +file(GLOB TRANSFORM_SSE "transform/*_sse.cpp") +file(GLOB TRANSFORM_SSE2 "transform/*_sse2.cpp") +file(GLOB TRANSFORM_AVX "transform/*_avx.cpp") +file(GLOB TRANSFORM_AVX2 "transform/*_avx2.cpp") +file(GLOB TRANSFORM_WASM "transform/*_wasm.cpp") + +list(REMOVE_ITEM CODESTREAM ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODESTREAM_WASM}) +list(REMOVE_ITEM CODING ${CODING_SSSE3} ${CODING_WASM} ${CODING_AVX512}) +list(REMOVE_ITEM TRANSFORM ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_WASM}) +list(APPEND SOURCES ${CODESTREAM} ${CODING} ${COMMON} ${OTHERS} ${TRANSFORM}) + +source_group("codestream" FILES ${CODESTREAM}) +source_group("coding" FILES ${CODING}) +source_group("common" FILES ${COMMON}) +source_group("others" FILES ${OTHERS}) +source_group("transform" FILES ${TRANSFORM}) + +configure_file( + "../pkg-config.pc.cmake" + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pc" +) + +if(EMSCRIPTEN) + add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) + add_library(openjph ${SOURCES}) + add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM}) + target_include_directories(openjph PUBLIC common) + target_include_directories(openjphsimd PUBLIC common) + target_compile_options(openjphsimd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128) + source_group("codestream" FILES ${CODESTREAM_WASM}) + source_group("coding" FILES ${CODING_WASM}) + source_group("transform" FILES ${TRANSFORM_WASM}) +elseif(NOT OJPH_DISABLE_INTEL_SIMD) + add_library(openjph ${SOURCES} ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODING_SSSE3} ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2}) + source_group("codestream" FILES ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2}) + source_group("coding" FILES ${CODING_SSSE3}) + source_group("transform" FILES ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2}) + if (OJPH_ENABLE_INTEL_AVX512) + target_sources(openjph PRIVATE ${CODING_AVX512}) + source_group("coding" FILES ${CODING_AVX512}) + endif() +else() + add_library(openjph ${SOURCES}) +endif() + +## include library version/name +target_include_directories(openjph PUBLIC common) +target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) + +if (MSVC) + set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512") + set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") +else() + set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + set_source_files_properties(src/core/coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3) + set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd) + set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) +endif() + +if (WIN32) + set(OJPH_LIB_NAME_STRING "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") + set_target_properties(openjph + PROPERTIES + OUTPUT_NAME "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") +else() + set(OJPH_LIB_NAME_STRING "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}") + set_target_properties(openjph + PROPERTIES + SOVERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}" + VERSION "${OPENJPH_VERSION}") +endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b597c265..fb2db788 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -43,12 +43,12 @@ include(GoogleTest) gtest_add_tests(TARGET test_executables) if (WIN32) - if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(CMAKE_BUILD_TYPE MATCHES "Debug") add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "../bin/Debug/gtest.dll" "./Debug/" COMMAND ${CMAKE_COMMAND} -E copy "../bin/Debug/gtest_main.dll" "./Debug/" ) - elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + elseif(CMAKE_BUILD_TYPE MATCHES "Release") add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest.dll" "./Release/" COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest_main.dll" "./Release/" diff --git a/tests/mse_pae.cmake b/tests/mse_pae.cmake index 90cea824..8187ce13 100644 --- a/tests/mse_pae.cmake +++ b/tests/mse_pae.cmake @@ -5,6 +5,8 @@ project (mse_pae DESCRIPTION "A program to find MSE and peak absolute error between two images" LANGUAGES CXX) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +include_directories(../src/apps/common) +include_directories(../src/core/common) # Configure source files set(mse_pae mse_pae.cpp "../src/apps/others/ojph_img_io.cpp" "../src/core/others/ojph_message.cpp" "../src/core/others/ojph_file.cpp" "../src/core/others/ojph_mem.cpp" "../src/core/others/ojph_arch.cpp") @@ -15,22 +17,20 @@ set(OJPH_IMG_IO_AVX2 "../src/apps/others/ojph_img_io_avx2.cpp") if(NOT OJPH_DISABLE_INTEL_SIMD) list(APPEND mse_pae ${OJPH_IMG_IO_SSE41}) list(APPEND mse_pae ${OJPH_IMG_IO_AVX2}) + # Set compilation flags + if (MSVC) + set_source_files_properties(../src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + else() + set_source_files_properties(../src/apps/others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(../src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + endif() endif() -# Set compilation flags -if (MSVC) - set_source_files_properties(../src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") -else() - set_source_files_properties(../src/apps/others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(../src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) -endif() # Add executable add_executable(mse_pae ${mse_pae}) # Add tiff library if it is available -IF( USE_TIFF ) +if( USE_TIFF ) target_link_libraries (mse_pae ${TIFF_LIBRARIES}) -ELSE() - target_link_libraries (mse_pae) -ENDIF() \ No newline at end of file +endif() diff --git a/tests/mse_pae.cpp b/tests/mse_pae.cpp index 9924aea8..84653399 100644 --- a/tests/mse_pae.cpp +++ b/tests/mse_pae.cpp @@ -40,8 +40,8 @@ #include #include #include -#include "../common/ojph_img_io.h" -#include "../common/ojph_mem.h" +#include "ojph_img_io.h" +#include "ojph_mem.h" using namespace ojph; using namespace std; diff --git a/tests/test_executables.cpp b/tests/test_executables.cpp index 696daadd..7b16b542 100644 --- a/tests/test_executables.cpp +++ b/tests/test_executables.cpp @@ -99,8 +99,8 @@ int execute(const std::string& cmd, std::string& result) #define REF_FILE_DIR ".\\jp2k_test_codestreams\\openjph\\references\\" #define MSE_PAE_PATH ".\\Release\\mse_pae" #define COMPARE_FILES_PATH ".\\Release\\compare_files" - #define EXPAND_EXECUTABLE "..\\..\\bin\\Release\\ojph_expand.exe" - #define COMPRESS_EXECUTABLE "..\\..\\bin\\Release\\ojph_compress.exe" + #define EXPAND_EXECUTABLE "..\\..\\bin\\ojph_expand.exe" + #define COMPRESS_EXECUTABLE "..\\..\\bin\\ojph_compress.exe" #else #define SRC_FILE_DIR "./jp2k_test_codestreams/openjph/" #define OUT_FILE_DIR "./" From c73f25121344c0660551423dcdfea37d3315a529 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Wed, 27 Dec 2023 20:34:17 +1100 Subject: [PATCH 05/13] Fixed the earlier error --- src/core/CMakeLists.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index dc87c5a1..64364ec5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -74,22 +74,22 @@ target_include_directories(openjph PUBLIC common) target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) if (MSVC) - set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") - set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512") - set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") - set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") - set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + set_source_files_properties(codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + set_source_files_properties(coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512") + set_source_files_properties(transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") + set_source_files_properties(transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") + set_source_files_properties(transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") else() - set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) - set_source_files_properties(src/core/coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3) - set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd) - set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) - set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) - set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + set_source_files_properties(codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + set_source_files_properties(coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3) + set_source_files_properties(coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd) + set_source_files_properties(transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) + set_source_files_properties(transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx) + set_source_files_properties(transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) endif() if (WIN32) From b06f663607ba981a5e77326c78fe270ffd7019e2 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 30 Dec 2023 12:45:56 +1100 Subject: [PATCH 06/13] Modified CMakeLists.txt to fix installing files. One problem, tests files are also copied when they are build. --- CMakeLists.txt | 6 ++++++ src/apps/CMakeLists.txt | 3 --- src/core/CMakeLists.txt | 3 --- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cf131cc..98b2e292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,12 @@ if (BUILD_SHARED_LIBS AND MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_BUILD_SHARED_LIBRARY\"") endif() +## specify output directories +## this will be refined further for Debug and Release builds in included CMakeLists.txt +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) + ## Build library and applications add_subdirectory(src/core) if (OJPH_BUILD_EXECUTABLES) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index b67a1dd5..9bece1a3 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -36,9 +36,6 @@ endif() ############################################################ ## Change folders -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index dc87c5a1..74065b78 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,7 +1,4 @@ -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) From 0de48e2858594d1eefc068bcf846bec9e5fb950a Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 30 Dec 2023 17:46:29 +1100 Subject: [PATCH 07/13] This improved wasm builds. It also removes all the warnings during wasm builds. --- src/apps/ojph_compress/CMakeLists.txt | 77 +++++++++++-------- src/apps/ojph_expand/CMakeLists.txt | 77 +++++++++++-------- src/apps/others/ojph_img_io.cpp | 2 +- src/core/codestream/ojph_codestream_local.cpp | 4 +- src/core/codestream/ojph_resolution.cpp | 5 +- src/core/codestream/ojph_subband.cpp | 6 +- 6 files changed, 103 insertions(+), 68 deletions(-) diff --git a/src/apps/ojph_compress/CMakeLists.txt b/src/apps/ojph_compress/CMakeLists.txt index 24f3112c..29b4201e 100644 --- a/src/apps/ojph_compress/CMakeLists.txt +++ b/src/apps/ojph_compress/CMakeLists.txt @@ -1,38 +1,55 @@ ## building ojph_compress ######################### -include_directories(../common) - -file(GLOB OJPH_COMPRESS "ojph_compress.cpp") -file(GLOB OJPH_IMG_IO "../others/ojph_img_io*.cpp") -file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") - -if(NOT OJPH_DISABLE_INTEL_SIMD) - list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_SSE41}) - list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_AVX2}) -endif() - -source_group("main" FILES ${OJPH_COMPRESS}) -source_group("others" FILES ${OJPH_IMG_IO}) -source_group("common" FILES ${OJPH_IMG_IO_H}) - if(OJPH_BUILD_EXECUTABLES) - add_executable(ojph_compress ${OJPH_COMPRESS} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) -endif() -if (MSVC) - set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") -else() - set_source_files_properties(../others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) -endif() - -if(OJPH_BUILD_EXECUTABLES) - if( USE_TIFF ) - target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) + include_directories(../common) + include_directories(../../core/common) + + file(GLOB OJPH_COMPRESS "ojph_compress.cpp") + file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") + file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") + file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") + file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + + list(APPEND SOURCES ${OJPH_COMPRESS} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) + + source_group("main" FILES ${OJPH_COMPRESS}) + source_group("others" FILES ${OJPH_IMG_IO}) + source_group("common" FILES ${OJPH_IMG_IO_H}) + + if(EMSCRIPTEN) + add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_compress ${SOURCES}) + add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) + target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) + source_group("others" FILES ${OJPH_IMG_IO_SSE4}) + + target_link_libraries(ojph_compress PRIVATE openjph) + install(TARGETS ojph_compress DESTINATION bin) + target_link_libraries(ojph_compress_simd PRIVATE openjphsimd) + install(TARGETS ojph_compress_simd DESTINATION bin) else() - target_link_libraries(ojph_compress PUBLIC openjph) + if(NOT OJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_compress ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) + + if (MSVC) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") + else() + set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) + endif() + else() + add_executable(ojph_compress ${SOURCES}) + endif() + + if( USE_TIFF ) + target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_compress PUBLIC openjph) + endif() + + install(TARGETS ojph_compress DESTINATION bin) endif() -endif() -install(TARGETS ojph_compress DESTINATION bin) \ No newline at end of file +endif() diff --git a/src/apps/ojph_expand/CMakeLists.txt b/src/apps/ojph_expand/CMakeLists.txt index 29644dfc..d93e568d 100644 --- a/src/apps/ojph_expand/CMakeLists.txt +++ b/src/apps/ojph_expand/CMakeLists.txt @@ -1,38 +1,55 @@ ## building ojph_expand ####################### -include_directories(../common) - -file(GLOB OJPH_EXPAND "ojph_expand.cpp") -file(GLOB OJPH_IMG_IO "../others/ojph_img_io*.cpp") -file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") - -if(NOT OJPH_DISABLE_INTEL_SIMD) - list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_SSE41}) - list(REMOVE_ITEM OJPH_IMG_IO ${OJPH_IMG_IO_AVX2}) -endif() - -source_group("main" FILES ${OJPH_EXPAND}) -source_group("others" FILES ${OJPH_IMG_IO}) -source_group("common" FILES ${OJPH_IMG_IO_H}) - if(OJPH_BUILD_EXECUTABLES) - add_executable(ojph_expand ${OJPH_EXPAND} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) -endif() -if (MSVC) - set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2") -else() - set_source_files_properties(../others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(../others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2) -endif() - -if(OJPH_BUILD_EXECUTABLES) - if( USE_TIFF ) - target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) + include_directories(../common) + include_directories(../../core/common) + + file(GLOB OJPH_EXPAND "ojph_expand.cpp") + file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") + file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") + file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") + file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + + list(APPEND SOURCES ${OJPH_EXPAND} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) + + source_group("main" FILES ${OJPH_EXPAND}) + source_group("others" FILES ${OJPH_IMG_IO}) + source_group("common" FILES ${OJPH_IMG_IO_H}) + + if(EMSCRIPTEN) + add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_expand ${SOURCES}) + add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) + target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) + source_group("others" FILES ${OJPH_IMG_IO_SSE4}) + + target_link_libraries(ojph_expand PRIVATE openjph) + install(TARGETS ojph_expand DESTINATION bin) + target_link_libraries(ojph_expand_simd PRIVATE openjphsimd) + install(TARGETS ojph_expand_simd DESTINATION bin) else() - target_link_libraries(ojph_expand PUBLIC openjph) + if(NOT OJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_expand ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) + + if (MSVC) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") + else() + set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) + endif() + else() + add_executable(ojph_expand ${SOURCES}) + endif() + + if( USE_TIFF ) + target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_expand PUBLIC openjph) + endif() + + install(TARGETS ojph_expand DESTINATION bin) endif() -endif() -install(TARGETS ojph_expand DESTINATION bin) +endif() diff --git a/src/apps/others/ojph_img_io.cpp b/src/apps/others/ojph_img_io.cpp index a83e5fc1..88fdcfc5 100644 --- a/src/apps/others/ojph_img_io.cpp +++ b/src/apps/others/ojph_img_io.cpp @@ -1650,7 +1650,7 @@ namespace ojph { be2le(offset_to_data_for_image_element_1); // set to starting point of image data - if (fseek(file_handle, offset_to_image_data_in_bytes, SEEK_SET) != 0) + if (fseek(file_handle, (long)offset_to_image_data_in_bytes, SEEK_SET) != 0) { close(); OJPH_ERROR(0x0300000E7, "Error reading file %s", filename); diff --git a/src/core/codestream/ojph_codestream_local.cpp b/src/core/codestream/ojph_codestream_local.cpp index cc074298..cb1a69b1 100644 --- a/src/core/codestream/ojph_codestream_local.cpp +++ b/src/core/codestream/ojph_codestream_local.cpp @@ -112,7 +112,7 @@ namespace ojph { OJPH_ERROR(0x00030011, "number of tiles cannot exceed 65535"); //allocate tiles - allocator->pre_alloc_obj(num_tiles.area()); + allocator->pre_alloc_obj((size_t)num_tiles.area()); ui32 num_tileparts = 0; point index; @@ -208,7 +208,7 @@ namespace ojph { allocator->post_alloc_obj(precinct_scratch_needed_bytes); //get tiles - tiles = this->allocator->post_alloc_obj(num_tiles.area()); + tiles = this->allocator->post_alloc_obj((size_t)num_tiles.area()); ui32 num_tileparts = 0; point index; diff --git a/src/core/codestream/ojph_resolution.cpp b/src/core/codestream/ojph_resolution.cpp index bde1b511..e1d78cba 100644 --- a/src/core/codestream/ojph_resolution.cpp +++ b/src/core/codestream/ojph_resolution.cpp @@ -160,7 +160,7 @@ namespace ojph { num_precincts.w -= trx0 >> log_PP.w; num_precincts.h = (try1 + (1 << log_PP.h) - 1) >> log_PP.h; num_precincts.h -= try0 >> log_PP.h; - allocator->pre_alloc_obj(num_precincts.area()); + allocator->pre_alloc_obj((size_t)num_precincts.area()); } //allocate lines @@ -262,7 +262,8 @@ namespace ojph { num_precincts.w -= trx0 >> log_PP.w; num_precincts.h = (try1 + (1 << log_PP.h) - 1) >> log_PP.h; num_precincts.h -= try0 >> log_PP.h; - precincts = allocator->post_alloc_obj(num_precincts.area()); + precincts = + allocator->post_alloc_obj((size_t)num_precincts.area()); ui64 num = num_precincts.area(); for (ui64 i = 0; i < num; ++i) precincts[i] = precinct(); diff --git a/src/core/codestream/ojph_subband.cpp b/src/core/codestream/ojph_subband.cpp index b41294e8..fc83bf2b 100644 --- a/src/core/codestream/ojph_subband.cpp +++ b/src/core/codestream/ojph_subband.cpp @@ -85,7 +85,7 @@ namespace ojph { allocator->pre_alloc_obj(num_blocks.w); //allocate codeblock headers - allocator->pre_alloc_obj(num_blocks.area()); + allocator->pre_alloc_obj((size_t)num_blocks.area()); for (ui32 i = 0; i < num_blocks.w; ++i) codeblock::pre_alloc(codestream, nominal); @@ -152,8 +152,8 @@ namespace ojph { blocks = allocator->post_alloc_obj(num_blocks.w); //allocate codeblock headers coded_cb_header *cp = coded_cbs = - allocator->post_alloc_obj(num_blocks.area()); - memset(coded_cbs, 0, sizeof(coded_cb_header) * num_blocks.area()); + allocator->post_alloc_obj((size_t)num_blocks.area()); + memset(coded_cbs, 0, sizeof(coded_cb_header) * (size_t)num_blocks.area()); for (int i = (int)num_blocks.area(); i > 0; --i, ++cp) cp->Kmax = K_max; From 3d8f5c82875fba711b5597be6a3df322631c47ed Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 30 Dec 2023 18:23:45 +1100 Subject: [PATCH 08/13] Removing CMAKD_CXX_FLAGS settings, and replacing them with add_definitions and add_compile_options. --- CMakeLists.txt | 24 +++++++++++------------- src/apps/CMakeLists.txt | 7 +------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98b2e292..24a8e8e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,30 +49,28 @@ include(ojph_libname.cmake) ## C++ version and flags set(CMAKE_CXX_STANDARD 14) if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /D \"_CRT_SECURE_NO_WARNINGS\"") + add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -Wall -Wextra -Wconversion -Wunused-parameter") + add_compile_options( + -fexceptions + -Wall + -Wextra + -Wconversion + -Wunused-parameter + ) endif() ## The option OJPH_DISABLE_INTEL_SIMD and OJPH_ENABLE_INTEL_AVX512 if (OJPH_DISABLE_INTEL_SIMD) - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_DISABLE_INTEL_SIMD\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_DISABLE_INTEL_SIMD") - endif() + add_definitions(-DOJPH_DISABLE_INTEL_SIMD) elseif (OJPH_ENABLE_INTEL_AVX512) - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_INTEL_AVX512\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_INTEL_AVX512") - endif() + add_definitions(-DOJPH_ENABLE_INTEL_AVX512) endif() ## The option BUILD_SHARED_LIBS if (BUILD_SHARED_LIBS AND MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_BUILD_SHARED_LIBRARY\"") + add_definitions(-DOJPH_BUILD_SHARED_LIBRARY) endif() ## specify output directories diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 9bece1a3..9795bb7a 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -24,12 +24,7 @@ if( OJPH_ENABLE_TIFF_SUPPORT ) if( TIFF_FOUND ) set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") include_directories( ${TIFF_INCLUDE_DIR} ) - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"OJPH_ENABLE_TIFF_SUPPORT\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOJPH_ENABLE_TIFF_SUPPORT") - endif() - #include_directories(${CMAKE_BINARY_DIR}/libtiff) # for tiffconf.h on windows + add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT) endif( TIFF_FOUND ) endif() From a3103d63c6045e400888a0e6a7a74a856c1e2c67 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Jan 2024 11:30:17 +1100 Subject: [PATCH 09/13] This is to fix MingW building. I also corrected some settings. MingW tests are not working yet. --- CMakeLists.txt | 38 ++++++++------- ojph_libname.cmake | 2 +- src/apps/CMakeLists.txt | 4 +- src/core/CMakeLists.txt | 10 ++-- src/core/common/ojph_file.h | 87 +++++++++++----------------------- src/core/common/ojph_version.h | 2 +- 6 files changed, 58 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a8e8e5..54e63e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ cmake_minimum_required(VERSION 3.11.0) +## Library name/version +include(ojph_libname.cmake) + ## project -project (openjph DESCRIPTION "Open source implementation of JPH" LANGUAGES CXX) +project (openjph VERSION ${OPENJPH_VERSION} DESCRIPTION "Open source implementation of JPH" LANGUAGES CXX) set_property(GLOBAL PROPERTY USE_FOLDERS ON) ################################################################################################ @@ -43,13 +46,10 @@ if (NOT CMAKE_BUILD_TYPE) endif() message(STATUS "Building ${CMAKE_BUILD_TYPE}") -## Library name -include(ojph_libname.cmake) - ## C++ version and flags set(CMAKE_CXX_STANDARD 14) if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_compile_options(-D_CRT_SECURE_NO_WARNINGS) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") add_compile_options( @@ -63,14 +63,9 @@ endif() ## The option OJPH_DISABLE_INTEL_SIMD and OJPH_ENABLE_INTEL_AVX512 if (OJPH_DISABLE_INTEL_SIMD) - add_definitions(-DOJPH_DISABLE_INTEL_SIMD) + add_compile_options(-DOJPH_DISABLE_INTEL_SIMD) elseif (OJPH_ENABLE_INTEL_AVX512) - add_definitions(-DOJPH_ENABLE_INTEL_AVX512) -endif() - -## The option BUILD_SHARED_LIBS -if (BUILD_SHARED_LIBS AND MSVC) - add_definitions(-DOJPH_BUILD_SHARED_LIBRARY) + add_compile_options(-DOJPH_ENABLE_INTEL_AVX512) endif() ## specify output directories @@ -89,18 +84,29 @@ endif() # Install ################################################################################################ +set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include") +set(PKG_CONFIG_LIBDIR "\${prefix}/lib") +set(PKG_CONFIG_LIBS "-lopenjph") + include(GNUInstallDirs) -install(TARGETS openjph LIBRARY - DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS openjph + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install (DIRECTORY src/core/common/ +install(DIRECTORY src/core/common/ DESTINATION include/openjph FILES_MATCHING PATTERN "*.h") -install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pc" +install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/pkg-config.pc.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" +) + ################################################################################################ # Testing (OJPH_BUILD_TESTS) ################################################################################################ diff --git a/ojph_libname.cmake b/ojph_libname.cmake index 942a62e9..8c9d6ecd 100644 --- a/ojph_libname.cmake +++ b/ojph_libname.cmake @@ -15,7 +15,7 @@ string(REGEX MATCH "OPENJPH_VERSION_MAJOR ([0-9]*)" _ ${VERFILE}) set(OPENJPH_VERSION_MAJOR ${CMAKE_MATCH_1}) string(REGEX MATCH "OPENJPH_VERSION_MINOR ([0-9]*)" _ ${VERFILE}) set(OPENJPH_VERSION_MINOR ${CMAKE_MATCH_1}) -string(REGEX MATCH "OPENJPH_VERSION_PATCH ([a-z0-9]*)" _ ${VERFILE}) +string(REGEX MATCH "OPENJPH_VERSION_PATCH ([0-9]*)" _ ${VERFILE}) set(OPENJPH_VERSION_PATCH ${CMAKE_MATCH_1}) set(OPENJPH_VERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}.${OPENJPH_VERSION_PATCH}") diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 9795bb7a..d0779aa3 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -2,7 +2,7 @@ ############################################################ if( OJPH_ENABLE_TIFF_SUPPORT ) - if( WIN32 ) + if( MSVC ) set(TIFF_INCLUDE_DIR "C:\\Program Files\\tiff\\include" CACHE PATH "the directory containing the TIFF headers") set(TIFF_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") @@ -17,7 +17,7 @@ if( OJPH_ENABLE_TIFF_SUPPORT ) message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) - endif( WIN32 ) + endif( MSVC ) FIND_PACKAGE( TIFF ) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f8b78ee0..e43b6977 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -38,11 +38,6 @@ source_group("common" FILES ${COMMON}) source_group("others" FILES ${OTHERS}) source_group("transform" FILES ${TRANSFORM}) -configure_file( - "../pkg-config.pc.cmake" - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pc" -) - if(EMSCRIPTEN) add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) add_library(openjph ${SOURCES}) @@ -66,6 +61,11 @@ else() add_library(openjph ${SOURCES}) endif() +## The option BUILD_SHARED_LIBS +if (BUILD_SHARED_LIBS AND WIN32) + target_compile_definitions(openjph PRIVATE OJPH_BUILD_SHARED_LIBRARY) +endif() + ## include library version/name target_include_directories(openjph PUBLIC common) target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) diff --git a/src/core/common/ojph_file.h b/src/core/common/ojph_file.h index 7faa6b0f..7d9efce6 100644 --- a/src/core/common/ojph_file.h +++ b/src/core/common/ojph_file.h @@ -71,7 +71,7 @@ namespace ojph { //////////////////////////////////////////////////////////////////////////// - class outfile_base + class OJPH_EXPORT outfile_base { public: @@ -84,24 +84,17 @@ namespace ojph { }; //////////////////////////////////////////////////////////////////////////// - class j2c_outfile : public outfile_base + class OJPH_EXPORT j2c_outfile : public outfile_base { public: - OJPH_EXPORT j2c_outfile() { fh = 0; } - OJPH_EXPORT - ~j2c_outfile() { if (fh) fclose(fh); } + ~j2c_outfile() override { if (fh) fclose(fh); } - OJPH_EXPORT void open(const char *filename); - OJPH_EXPORT - virtual size_t write(const void *ptr, size_t size); - OJPH_EXPORT - virtual si64 tell(); - OJPH_EXPORT - virtual void flush(); - OJPH_EXPORT - virtual void close(); + size_t write(const void *ptr, size_t size) override; + si64 tell() override; + void flush() override; + void close() override; private: FILE *fh; @@ -120,15 +113,13 @@ namespace ojph { * * memory data can be accessed using get_data() */ - class mem_outfile : public outfile_base + class OJPH_EXPORT mem_outfile : public outfile_base { public: /** A constructor */ - OJPH_EXPORT mem_outfile(); /** A destructor */ - OJPH_EXPORT - ~mem_outfile(); + ~mem_outfile() override; /** Call this function to open a memory file. * @@ -138,7 +129,6 @@ namespace ojph { * @param initial_size is the initial memory buffer size. * The default value is 2^16. */ - OJPH_EXPORT void open(size_t initial_size = 65536); /** Call this function to write data to the memory file. @@ -149,23 +139,20 @@ namespace ojph { * @param ptr is the address of the new data. * @param size the number of bytes in the new data. */ - OJPH_EXPORT - virtual size_t write(const void *ptr, size_t size); + size_t write(const void *ptr, size_t size) override; /** Call this function to know the file size (i.e., number of bytes used * to store the file). * * @return the file size. */ - OJPH_EXPORT - virtual si64 tell() { return cur_ptr - buf; } + si64 tell() override { return cur_ptr - buf; } /** Call this function to close the file and deallocate memory * * The object can be used again after calling close */ - OJPH_EXPORT - virtual void close(); + void close() override; /** Call this function to access memory file data. * @@ -174,7 +161,6 @@ namespace ojph { * * @return a constant pointer to the data. */ - OJPH_EXPORT const ui8* get_data() { return buf; } /** Call this function to access memory file data (for const objects) @@ -184,7 +170,6 @@ namespace ojph { * * @return a constant pointer to the data. */ - OJPH_EXPORT const ui8* get_data() const { return buf; } private: @@ -195,7 +180,7 @@ namespace ojph { }; //////////////////////////////////////////////////////////////////////////// - class infile_base + class OJPH_EXPORT infile_base { public: enum seek : int { @@ -216,64 +201,46 @@ namespace ojph { }; //////////////////////////////////////////////////////////////////////////// - class j2c_infile : public infile_base + class OJPH_EXPORT j2c_infile : public infile_base { public: - OJPH_EXPORT j2c_infile() { fh = 0; } - OJPH_EXPORT - ~j2c_infile() { if (fh) fclose(fh); } + ~j2c_infile() override { if (fh) fclose(fh); } - OJPH_EXPORT void open(const char *filename); //read reads size bytes, returns the number of bytes read - OJPH_EXPORT - virtual size_t read(void *ptr, size_t size); + size_t read(void *ptr, size_t size) override; //seek returns 0 on success - OJPH_EXPORT - virtual int seek(si64 offset, enum infile_base::seek origin); - OJPH_EXPORT - virtual si64 tell(); - OJPH_EXPORT - virtual bool eof() { return feof(fh) != 0; } - OJPH_EXPORT - virtual void close(); + int seek(si64 offset, enum infile_base::seek origin) override; + si64 tell() override; + bool eof() override { return feof(fh) != 0; } + void close() override; private: FILE *fh; - }; //////////////////////////////////////////////////////////////////////////// - class mem_infile : public infile_base + class OJPH_EXPORT mem_infile : public infile_base { public: - OJPH_EXPORT mem_infile() { close(); } - OJPH_EXPORT - ~mem_infile() { } + ~mem_infile() override { } - OJPH_EXPORT void open(const ui8* data, size_t size); //read reads size bytes, returns the number of bytes read - OJPH_EXPORT - virtual size_t read(void *ptr, size_t size); + size_t read(void *ptr, size_t size) override; //seek returns 0 on success - OJPH_EXPORT - virtual int seek(si64 offset, enum infile_base::seek origin); - OJPH_EXPORT - virtual si64 tell() { return cur_ptr - data; } - OJPH_EXPORT - virtual bool eof() { return cur_ptr >= data + size; } - OJPH_EXPORT - virtual void close() { data = cur_ptr = NULL; size = 0; } + int seek(si64 offset, enum infile_base::seek origin) override; + si64 tell() override { return cur_ptr - data; } + bool eof() override { return cur_ptr >= data + size; } + void close() override { data = cur_ptr = NULL; size = 0; } private: const ui8 *data, *cur_ptr; size_t size; - }; diff --git a/src/core/common/ojph_version.h b/src/core/common/ojph_version.h index 09812863..1d537a94 100644 --- a/src/core/common/ojph_version.h +++ b/src/core/common/ojph_version.h @@ -35,4 +35,4 @@ #define OPENJPH_VERSION_MAJOR 0 #define OPENJPH_VERSION_MINOR 10 -#define OPENJPH_VERSION_PATCH beta0 +#define OPENJPH_VERSION_PATCH 0 From a730206367e5a8da1c67b4c8189eae819ae2cdeb Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Jan 2024 11:49:43 +1100 Subject: [PATCH 10/13] This addresses tests on MSys compilation. --- tests/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fb2db788..08fd2f90 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries( include(GoogleTest) gtest_add_tests(TARGET test_executables) -if (WIN32) +if (MSVC) if(CMAKE_BUILD_TYPE MATCHES "Debug") add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "../bin/Debug/gtest.dll" "./Debug/" @@ -54,4 +54,9 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy "../bin/Release/gtest_main.dll" "./Release/" ) endif() +elseif(MSYS) + add_custom_command(TARGET test_executables POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "../bin/msys-gtest.dll" "./" + COMMAND ${CMAKE_COMMAND} -E copy "../bin/msys-gtest_main.dll" "./" + ) endif() From ea6fb2e5ef271e08e434f65d533f41b32be4c7df Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Jan 2024 12:10:37 +1100 Subject: [PATCH 11/13] Test if this works --- .github/workflows/ccp-workflow.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ccp-workflow.yml b/.github/workflows/ccp-workflow.yml index 8eedc0ab..d691a69b 100644 --- a/.github/workflows/ccp-workflow.yml +++ b/.github/workflows/ccp-workflow.yml @@ -5,11 +5,19 @@ on: push jobs: build: - name: main build for Unix-like - runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-20.04, ubuntu-latest] + include: [ + { system: MINGW64, runner: windows-2022 }, + { system: MINGW32, runner: windows-2022 }, + { system: UCRT64, runner: windows-2022 }, + { system: CLANG64, runner: windows-2022 }, + { system: CLANG32, runner: windows-2022 }, + { system: MACOS, runner: macos-latest }, + { system: UBUNTU, runner: ubuntu-latest }, + ] + name: ${{ matrix.system }} + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 - name: cmake From b20bcb1e00e8096b95ee44c745f5fee42e0ae14b Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Jan 2024 12:19:29 +1100 Subject: [PATCH 12/13] The previous test did not work. This is to correct it. --- .github/workflows/ccp-workflow.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ccp-workflow.yml b/.github/workflows/ccp-workflow.yml index d691a69b..9b388901 100644 --- a/.github/workflows/ccp-workflow.yml +++ b/.github/workflows/ccp-workflow.yml @@ -8,15 +8,11 @@ jobs: strategy: matrix: include: [ - { system: MINGW64, runner: windows-2022 }, - { system: MINGW32, runner: windows-2022 }, - { system: UCRT64, runner: windows-2022 }, - { system: CLANG64, runner: windows-2022 }, - { system: CLANG32, runner: windows-2022 }, - { system: MACOS, runner: macos-latest }, - { system: UBUNTU, runner: ubuntu-latest }, + { system: MacOS, runner: macos-latest }, + { system: Ubuntu-20, runner: ubuntu-20.04 }, + { system: Ubuntu-latest, runner: ubuntu-latest }, ] - name: ${{ matrix.system }} + name: ${{ matrix.system }} Build runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 @@ -28,11 +24,14 @@ jobs: working-directory: build test: - name: tests on Linux and MacOS - runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] + include: [ + { system: MacOS, runner: macos-latest }, + { system: Ubuntu-latest, runner: ubuntu-latest }, + ] + name: ${{ matrix.system }} Test + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 - name: cmake @@ -46,11 +45,13 @@ jobs: working-directory: build test_windows: - name: tests on Windows - runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] + include: [ + { system: Windows, runner: windows-latest }, + ] + name: ${{ matrix.system }} Test + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 - name: cmake From fbaedb302c1c0d0539a86cdb08d2e28c1e860033 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Jan 2024 13:22:54 +1100 Subject: [PATCH 13/13] Improvement to CMakeLists.txt files. Now, in windows, tiff library files are copied to the bin folder. --- src/apps/CMakeLists.txt | 101 +++++++++++++++----------- src/apps/ojph_compress/CMakeLists.txt | 90 +++++++++++------------ src/apps/ojph_expand/CMakeLists.txt | 89 +++++++++++------------ 3 files changed, 145 insertions(+), 135 deletions(-) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index d0779aa3..1af20d7e 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -1,43 +1,58 @@ -# Add tiff library -############################################################ -if( OJPH_ENABLE_TIFF_SUPPORT ) - - if( MSVC ) - - set(TIFF_INCLUDE_DIR "C:\\Program Files\\tiff\\include" CACHE PATH "the directory containing the TIFF headers") - set(TIFF_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") - set(TIFF_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") - set(TIFFXX_LIBRARY_DEBUG "C:\\Program Files\\tiff\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") - set(TIFFXX_LIBRARY_RELEASE "C:\\Program Files\\tiff\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") - - message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) - message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) - message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) - message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) - message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) - message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) - - endif( MSVC ) - - FIND_PACKAGE( TIFF ) - - if( TIFF_FOUND ) - set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") - include_directories( ${TIFF_INCLUDE_DIR} ) - add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT) - endif( TIFF_FOUND ) - -endif() -############################################################ - -## Change folders -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) - -## Build executables -add_subdirectory(ojph_expand) -add_subdirectory(ojph_compress) \ No newline at end of file + +if(OJPH_BUILD_EXECUTABLES) + + # Add tiff library + ############################################################ + if( OJPH_ENABLE_TIFF_SUPPORT ) + + if( MSVC ) + + set(TIFF_PATH "C:\\Program Files\\tiff") + set(TIFF_INCLUDE_DIR "${TIFF_PATH}\\include" CACHE PATH "the directory containing the TIFF headers") + set(TIFF_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") + set(TIFF_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") + set(TIFFXX_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") + set(TIFFXX_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") + + message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) + message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) + message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) + message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) + message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) + message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) + + endif( MSVC ) + + FIND_PACKAGE( TIFF ) + + if( TIFF_FOUND ) + set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") + include_directories( ${TIFF_INCLUDE_DIR} ) + add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT) + endif( TIFF_FOUND ) + + endif() + ############################################################ + + ## Change folders + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) + + ## Build executables + add_subdirectory(ojph_expand) + add_subdirectory(ojph_compress) + + if (MSVC AND OJPH_ENABLE_TIFF_SUPPORT) + if (CMAKE_BUILD_TYPE MATCHES "Release") + file(COPY "${TIFF_PATH}\\bin\\tiff.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + file(COPY "${TIFF_PATH}\\bin\\tiffxx.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + elseif(CMAKE_BUILD_TYPE MATCHES "Debug") + file(COPY "${TIFF_PATH}\\bin\\tiffd.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + file(COPY "${TIFF_PATH}\\bin\\tiffxxd.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + endif() + endif() +endif() diff --git a/src/apps/ojph_compress/CMakeLists.txt b/src/apps/ojph_compress/CMakeLists.txt index 29b4201e..3dd3c59a 100644 --- a/src/apps/ojph_compress/CMakeLists.txt +++ b/src/apps/ojph_compress/CMakeLists.txt @@ -1,55 +1,53 @@ ## building ojph_compress ######################### -if(OJPH_BUILD_EXECUTABLES) - - include_directories(../common) - include_directories(../../core/common) - - file(GLOB OJPH_COMPRESS "ojph_compress.cpp") - file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") - file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") - file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") - file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") - - list(APPEND SOURCES ${OJPH_COMPRESS} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) - - source_group("main" FILES ${OJPH_COMPRESS}) - source_group("others" FILES ${OJPH_IMG_IO}) - source_group("common" FILES ${OJPH_IMG_IO_H}) - - if(EMSCRIPTEN) - add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) - add_executable(ojph_compress ${SOURCES}) - add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) - target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) - source_group("others" FILES ${OJPH_IMG_IO_SSE4}) - - target_link_libraries(ojph_compress PRIVATE openjph) - install(TARGETS ojph_compress DESTINATION bin) - target_link_libraries(ojph_compress_simd PRIVATE openjphsimd) - install(TARGETS ojph_compress_simd DESTINATION bin) - else() - if(NOT OJPH_DISABLE_INTEL_SIMD) - add_executable(ojph_compress ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) - - if (MSVC) - set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") - else() - set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) - endif() +include_directories(../common) +include_directories(../../core/common) + +file(GLOB OJPH_COMPRESS "ojph_compress.cpp") +file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") +file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") +file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") +file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + +list(APPEND SOURCES ${OJPH_COMPRESS} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) + +source_group("main" FILES ${OJPH_COMPRESS}) +source_group("others" FILES ${OJPH_IMG_IO}) +source_group("common" FILES ${OJPH_IMG_IO_H}) + +if(EMSCRIPTEN) + add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_compress ${SOURCES}) + add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) + target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) + source_group("others" FILES ${OJPH_IMG_IO_SSE4}) + + target_link_libraries(ojph_compress PRIVATE openjph) + install(TARGETS ojph_compress DESTINATION bin) + target_link_libraries(ojph_compress_simd PRIVATE openjphsimd) + install(TARGETS ojph_compress_simd DESTINATION bin) +else() + if(NOT OJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_compress ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) + + if (MSVC) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") else() - add_executable(ojph_compress ${SOURCES}) - endif() - - if( USE_TIFF ) - target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) - else() - target_link_libraries(ojph_compress PUBLIC openjph) + set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) endif() + else() + add_executable(ojph_compress ${SOURCES}) + endif() - install(TARGETS ojph_compress DESTINATION bin) + if( USE_TIFF ) + target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_compress PUBLIC openjph) endif() + install(TARGETS ojph_compress DESTINATION bin) + endif() + diff --git a/src/apps/ojph_expand/CMakeLists.txt b/src/apps/ojph_expand/CMakeLists.txt index d93e568d..f7b1ed33 100644 --- a/src/apps/ojph_expand/CMakeLists.txt +++ b/src/apps/ojph_expand/CMakeLists.txt @@ -1,55 +1,52 @@ ## building ojph_expand ####################### -if(OJPH_BUILD_EXECUTABLES) - - include_directories(../common) - include_directories(../../core/common) - - file(GLOB OJPH_EXPAND "ojph_expand.cpp") - file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") - file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") - file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") - file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") - - list(APPEND SOURCES ${OJPH_EXPAND} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) - - source_group("main" FILES ${OJPH_EXPAND}) - source_group("others" FILES ${OJPH_IMG_IO}) - source_group("common" FILES ${OJPH_IMG_IO_H}) - - if(EMSCRIPTEN) - add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) - add_executable(ojph_expand ${SOURCES}) - add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) - target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) - source_group("others" FILES ${OJPH_IMG_IO_SSE4}) - - target_link_libraries(ojph_expand PRIVATE openjph) - install(TARGETS ojph_expand DESTINATION bin) - target_link_libraries(ojph_expand_simd PRIVATE openjphsimd) - install(TARGETS ojph_expand_simd DESTINATION bin) - else() - if(NOT OJPH_DISABLE_INTEL_SIMD) - add_executable(ojph_expand ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) - - if (MSVC) - set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") - else() - set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) - set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) - endif() - else() - add_executable(ojph_expand ${SOURCES}) - endif() - - if( USE_TIFF ) - target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) +include_directories(../common) +include_directories(../../core/common) + +file(GLOB OJPH_EXPAND "ojph_expand.cpp") +file(GLOB OJPH_IMG_IO "../others/ojph_img_io.cpp") +file(GLOB OJPH_IMG_IO_SSE4 "../others/ojph_img_io_sse41.cpp") +file(GLOB OJPH_IMG_IO_AVX2 "../others/ojph_img_io_avx2.cpp") +file(GLOB OJPH_IMG_IO_H "../common/ojph_img_io.h") + +list(APPEND SOURCES ${OJPH_EXPAND} ${OJPH_IMG_IO} ${OJPH_IMG_IO_H}) + +source_group("main" FILES ${OJPH_EXPAND}) +source_group("others" FILES ${OJPH_IMG_IO}) +source_group("common" FILES ${OJPH_IMG_IO_H}) + +if(EMSCRIPTEN) + add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_expand ${SOURCES}) + add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4}) + target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1) + source_group("others" FILES ${OJPH_IMG_IO_SSE4}) + + target_link_libraries(ojph_expand PRIVATE openjph) + install(TARGETS ojph_expand DESTINATION bin) + target_link_libraries(ojph_expand_simd PRIVATE openjphsimd) + install(TARGETS ojph_expand_simd DESTINATION bin) +else() + if(NOT OJPH_DISABLE_INTEL_SIMD) + add_executable(ojph_expand ${SOURCES} ${OJPH_IMG_IO_SSE4} ${OJPH_IMG_IO_AVX2}) + + if (MSVC) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS "/arch:AVX2") else() - target_link_libraries(ojph_expand PUBLIC openjph) + set_source_files_properties(${OJPH_IMG_IO_SSE4} PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(${OJPH_IMG_IO_AVX2} PROPERTIES COMPILE_FLAGS -mavx2) endif() + else() + add_executable(ojph_expand ${SOURCES}) + endif() - install(TARGETS ojph_expand DESTINATION bin) + if( USE_TIFF ) + target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}) + else() + target_link_libraries(ojph_expand PUBLIC openjph) endif() + install(TARGETS ojph_expand DESTINATION bin) + endif()