aboutsummaryrefslogtreecommitdiff
path: root/cmake/CompilerOptimizations.cmake
diff options
context:
space:
mode:
authorRichard Knight <q@1bpm.net>2021-07-21 22:22:01 +0100
committerRichard Knight <q@1bpm.net>2021-07-21 22:22:01 +0100
commitf71024077af151e0eeb37151fb0754e61ee9a2ea (patch)
tree89b59784cc7a0064ecd20ce783488a9522d8ff76 /cmake/CompilerOptimizations.cmake
parent1b40e87a3f54a70d4994262dd7fad4297caaeca3 (diff)
downloadcsound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.tar.gz
csound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.tar.bz2
csound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.zip
new cmake approach
Diffstat (limited to 'cmake/CompilerOptimizations.cmake')
-rw-r--r--cmake/CompilerOptimizations.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/cmake/CompilerOptimizations.cmake b/cmake/CompilerOptimizations.cmake
new file mode 100644
index 0000000..543daf8
--- /dev/null
+++ b/cmake/CompilerOptimizations.cmake
@@ -0,0 +1,53 @@
+
+check_c_compiler_flag(-ftree-vectorize HAS_TREE_VECTORIZE)
+check_cxx_compiler_flag(-ftree-vectorize HAS_CXX_TREE_VECTORIZE)
+if (HAS_TREE_VECTORISE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftree-vectorize")
+endif()
+if (HAS_CXX_TREE_VECTORISE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftree-vectorize")
+endif()
+
+
+check_c_compiler_flag(-ffast-math HAS_FAST_MATH)
+check_cxx_compiler_flag(-ffast-math HAS_CXX_FAST_MATH)
+if (HAS_FAST_MATH AND NOT MINGW)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffast-math")
+endif()
+if (HAS_CXX_FAST_MATH AND NOT MINGW)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
+endif()
+
+
+
+if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+check_c_compiler_flag(-mfpmath=sse HAS_FPMATH_SSE)
+check_cxx_compiler_flag(-mfpmath=sse HAS_CXX_FPMATH_SSE)
+ if (HAS_FPMATH_SSE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse")
+endif()
+if (HAS_CXX_FPMATH_SSE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse")
+endif()
+
+endif()
+
+
+check_c_compiler_flag(-msse2 HAS_SSE2)
+check_cxx_compiler_flag(-msse2 HAS_CXX_SSE2)
+ if (HAS_SSE2 AND NOT IOS AND NOT WASM)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
+endif()
+if (HAS_CXX_SSE2 AND NOT IOS AND NOT WASM)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
+endif()
+
+
+check_c_compiler_flag(-fomit-frame-pointer HAS_OMIT_FRAME_POINTER)
+check_cxx_compiler_flag(-fomit-frame-pointer HAS_CXX_OMIT_FRAME_POINTER)
+if (HAS_OMIT_FRAME_POINTER)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
+endif()
+if (HAS_CXX_OMIT_FRAME_POINTER)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer")
+endif()