11cmake_minimum_required (VERSION 3.11.0)
22
33## Library name/version
4- include (ojph_libname .cmake)
4+ include (ojph_version .cmake)
55
66## project
77project (openjph VERSION ${OPENJPH_VERSION} DESCRIPTION "Open source implementation of JPH" LANGUAGES CXX)
@@ -11,21 +11,63 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1111# Building OpenJPH
1212################################################################################################
1313
14+ ## Target architecture
15+ # We use the target architecture to help with arranging files in "source_group" commands.
16+ # The code does not use the results provided by target_arch.cmake, and relies, instead,
17+ # on its own logic, which matches that in target_arch.cmake, to identify the architecture
18+ include (target_arch.cmake)
19+ target_architecture(OJPH_TARGET_ARCH)
20+ message (STATUS "CPU Architecture is ${OJPH_TARGET_ARCH} " )
21+
1422## options
15- option (OJPH_DISABLE_INTEL_SIMD "Disables the use of SIMD instructions and associated files" OFF )
16- option (OJPH_ENABLE_INTEL_AVX512 "enables the use of AVX512 SIMD instructions and associated files" ON )
1723option (BUILD_SHARED_LIBS "Shared Libraries" ON )
1824option (OJPH_ENABLE_TIFF_SUPPORT "Enables input and output support for TIFF files" ON )
1925option (OJPH_BUILD_TESTS "Enables building test code" OFF )
2026option (OJPH_BUILD_EXECUTABLES "Enables building command line executables" ON )
2127option (OJPH_BUILD_STREAM_EXPAND "Enables building ojph_stream_expand executable" OFF )
2228
29+ option (OJPH_DISABLE_SIMD "Disables the use of SIMD instructions -- agnostic to architectures" OFF )
30+ option (OJPH_DISABLE_SSE "Disables the use of SSE SIMD instructions and associated files" OFF )
31+ option (OJPH_DISABLE_SSE2 "Disables the use of SSE2 SIMD instructions and associated files" OFF )
32+ option (OJPH_DISABLE_SSSE3 "Disables the use of SSSE3 SIMD instructions and associated files" OFF )
33+ option (OJPH_DISABLE_SSE4 "Disables the use of SSE4 SIMD instructions and associated files" OFF )
34+ option (OJPH_DISABLE_AVX "Disables the use of AVX SIMD instructions and associated files" OFF )
35+ option (OJPH_DISABLE_AVX2 "Disables the use of AVX2 SIMD instructions and associated files" OFF )
36+ option (OJPH_DISABLE_AVX512 "Disables the use of AVX512 SIMD instructions and associated files" OFF )
37+ option (OJPH_DISABLE_NEON "Disables the use of NEON SIMD instructions and associated files" OFF )
38+
39+ ## options that are being deprecated
40+ if (DEFINED OJPH_DISABLE_INTEL_SIMD)
41+ message (STATUS "OJPH_DISABLE_INTEL_SIMD is being deprecated. Instead, use \" OJPH_DISABLE_SIMD\" , "
42+ "which is architecture agnostic. If you do not specify any, the default is "
43+ "OJPH_DISABLE_SIMD=OFF." )
44+ set (OJPH_DISABLE_SIMD ${OJPH_DISABLE_INTEL_SIMD} )
45+ message (STATUS "OJPH_DISABLE_SIMD is set to ${OJPH_DISABLE_SIMD} " )
46+ unset (OJPH_DISABLE_INTEL_SIMD)
47+ endif ()
48+ if (DEFINED OJPH_ENABLE_INTEL_AVX512)
49+ message (STATUS "OJPH_ENABLE_INTEL_AVX512 is being deprecated, use \" OJPH_DISABLE_AVX512\" instead."
50+ "If you do not specify any, the default is OJPH_DISABLE_AVX512=OFF." )
51+ if (OJPH_ENABLE_INTEL_AVX512)
52+ set (OJPH_DISABLE_AVX512 OFF )
53+ else ()
54+ set (OJPH_DISABLE_AVX512 ON )
55+ endif ()
56+ message (STATUS "OJPH_DISABLE_AVX512 is set to ${OJPH_DISABLE_AVX512} " )
57+ unset (OJPH_ENABLE_INTEL_AVX512)
58+ endif ()
59+
2360## Setting some of the options if EMSCRIPTEN is the compiler
61+ # WebAssembly SIMD is treated differently. The SIMD flags above have no effect on the
62+ # use of WASM SIMD. This is because, for WASM, both non-SIMD and SIMD are required,
63+ # and therefore two sets of binaries are generated. For CPUs, one binary can carry both
64+ # non-SIMD and SIMD, and the program, at run-time, can decide which path to follow,
65+ # depending on what CPU instructions are available.
2466if (EMSCRIPTEN)
25- set (OJPH_DISABLE_INTEL_SIMD ON )
2667 set (BUILD_SHARED_LIBS OFF )
2768 set (OJPH_ENABLE_TIFF_SUPPORT OFF )
2869 set (OJPH_BUILD_STREAM_EXPAND OFF )
70+ set (OJPH_DISABLE_SIMD ON )
2971endif ()
3072
3173# This is related to how the timestamp is set for URL downloaded files.
@@ -36,15 +78,16 @@ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
3678 endif ()
3779endif ()
3880
81+ ## Added by Michael Smith
3982set (CMAKE_CXX_FLAGS_ASAN
4083 "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
4184 CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds."
4285 FORCE)
4386
44- ## build type
87+ ## Build type
4588if (NOT CMAKE_BUILD_TYPE )
4689 set (CMAKE_BUILD_TYPE "Release" )
47- message ( STATUS "To use AddressSanitizer, use \" cmake .. -DCMAKE_BUILD_TYPE=asan\" " )
90+ message (STATUS "To use AddressSanitizer, use \" cmake .. -DCMAKE_BUILD_TYPE=asan\" " )
4891endif ()
4992message (STATUS "Building ${CMAKE_BUILD_TYPE} " )
5093
@@ -64,11 +107,34 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
64107 )
65108endif ()
66109
67- ## The option OJPH_DISABLE_INTEL_SIMD and OJPH_ENABLE_INTEL_AVX512
68- if (OJPH_DISABLE_INTEL_SIMD)
69- add_compile_definitions (OJPH_DISABLE_INTEL_SIMD)
70- elseif (OJPH_ENABLE_INTEL_AVX512)
71- add_compile_definitions (OJPH_ENABLE_INTEL_AVX512)
110+ ## Enhanced instruction options
111+ if (OJPH_DISABLE_SIMD)
112+ add_compile_definitions (OJPH_DISABLE_SIMD)
113+ else ()
114+ if (OJPH_DISABLE_SSE)
115+ add_compile_definitions (OJPH_DISABLE_SSE)
116+ endif ()
117+ if (OJPH_DISABLE_SSE2)
118+ add_compile_definitions (OJPH_DISABLE_SSE2)
119+ endif ()
120+ if (OJPH_DISABLE_SSSE3)
121+ add_compile_definitions (OJPH_DISABLE_SSSE3)
122+ endif ()
123+ if (OJPH_DISABLE_SSE4)
124+ add_compile_definitions (OJPH_DISABLE_SSE4)
125+ endif ()
126+ if (OJPH_DISABLE_AVX)
127+ add_compile_definitions (OJPH_DISABLE_AVX)
128+ endif ()
129+ if (OJPH_DISABLE_AVX2)
130+ add_compile_definitions (OJPH_DISABLE_AVX2)
131+ endif ()
132+ if (OJPH_DISABLE_AVX512)
133+ add_compile_definitions (OJPH_DISABLE_AVX512)
134+ endif ()
135+ if (OJPH_DISABLE_NEON)
136+ add_compile_definitions (OJPH_DISABLE_NEON)
137+ endif ()
72138endif ()
73139
74140## Build library and applications
0 commit comments