From 8a10a3323e09b3d5b70f9c8d8bff90f90a2b532e Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Thu, 2 Jan 2025 23:21:33 +0000 Subject: [PATCH] capture compilation flags into binary --- CMakeLists.txt | 15 ++++++++++----- src/main.c | 1 + test/perf_xlating.c | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d9bdd..49d5b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,9 @@ cmake_minimum_required(VERSION 2.8) project(sdr-server) - +set(CMAKE_C_STANDARD 11) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffast-math -std=c11") -if(CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage ") -endif() +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} --coverage") if(NO_MANUAL_SIMD) add_definitions(-DNO_MANUAL_SIMD) @@ -13,6 +11,13 @@ else() remove_definitions(-DNO_MANUAL_SIMD) endif() +if(CMAKE_BUILD_TYPE MATCHES Debug) + set(BUILD_COMPILATION_FLAGS "${CMAKE_C_FLAGS_DEBUG}") +elseif(CMAKE_BUILD_TYPE MATCHES Release) + set(BUILD_COMPILATION_FLAGS "${CMAKE_C_FLAGS_RELEASE}") +endif() +add_definitions(-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${BUILD_COMPILATION_FLAGS}") + add_library(sdr_serverLib ${CMAKE_CURRENT_SOURCE_DIR}/src/config.c ${CMAKE_CURRENT_SOURCE_DIR}/src/sdr_device.c diff --git a/src/main.c b/src/main.c index 919911c..8d9d261 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,7 @@ int main(int argc, char **argv) { } setvbuf(stdout, NULL, _IOLBF, 0); printf("SIMD optimization: %s\n", SIMD_STATUS); + printf("compilation flags: %s\n", CMAKE_C_FLAGS); struct server_config *server_config = NULL; int code = create_server_config(&server_config, argv[1]); if (code != 0) { diff --git a/test/perf_xlating.c b/test/perf_xlating.c index dac227c..71e74ad 100644 --- a/test/perf_xlating.c +++ b/test/perf_xlating.c @@ -8,6 +8,7 @@ extern const char *SIMD_STATUS; int main(void) { printf("SIMD optimization: %s\n", SIMD_STATUS); + printf("compilation flags: %s\n", CMAKE_C_FLAGS); uint32_t sampling_freq = 2016000; uint32_t target_freq = 48000; float *taps = NULL;