summaryrefslogtreecommitdiff
path: root/stacks/crdop/cmake/CRDOPCompiler.cmake
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-07 18:23:28 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-07 18:23:28 +0000
commitfa05a5f8238e9e1417235711656e5062ccc843a7 (patch)
tree46fbbd18de54492b59307c16efcc7f3152723238 /stacks/crdop/cmake/CRDOPCompiler.cmake
Initial push
Diffstat (limited to 'stacks/crdop/cmake/CRDOPCompiler.cmake')
-rw-r--r--stacks/crdop/cmake/CRDOPCompiler.cmake37
1 files changed, 37 insertions, 0 deletions
diff --git a/stacks/crdop/cmake/CRDOPCompiler.cmake b/stacks/crdop/cmake/CRDOPCompiler.cmake
new file mode 100644
index 0000000..e1aab37
--- /dev/null
+++ b/stacks/crdop/cmake/CRDOPCompiler.cmake
@@ -0,0 +1,37 @@
+# CRDOP compiler detection and warning flags (GCC, Clang, MSVC)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(CRDOP_COMPILER "gcc")
+elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang")
+ set(CRDOP_COMPILER "clang")
+elseif(MSVC)
+ set(CRDOP_COMPILER "msvc")
+else()
+ set(CRDOP_COMPILER "${CMAKE_C_COMPILER_ID}")
+endif()
+
+message(STATUS "CRDOP compiler=${CRDOP_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
+
+function(crdop_set_compile_options target)
+ if(MSVC)
+ target_compile_options(${target} PRIVATE /W3 /utf-8)
+ else()
+ target_compile_options(${target} PRIVATE -Wall -Wextra -Wno-unused-parameter)
+ if(CRDOP_COMPILER STREQUAL "clang")
+ target_compile_options(${target} PRIVATE
+ -Wno-gnu-zero-variadic-macro-arguments
+ -Wno-deprecated-non-prototype
+ )
+ endif()
+ if(CMAKE_BUILD_TYPE STREQUAL "Release")
+ target_compile_options(${target} PRIVATE -O2)
+ endif()
+ endif()
+endfunction()
+
+include(CheckLinkerFlag)
+if(NOT WIN32 AND NOT APPLE)
+ check_linker_flag(C "-Wl,--wrap=malloc" CRDOP_LINKER_SUPPORTS_WRAP)
+else()
+ set(CRDOP_LINKER_SUPPORTS_WRAP FALSE)
+endif()
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com