From 633d588aa442cbbf1571e55d4c635c3485b7331d Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sun, 3 Aug 2025 20:27:55 +0200 Subject: [PATCH] link libs when needed --- CMakeLists.txt | 20 ++++++++++++++------ src/fm95.c | 8 ++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd6acb8..cff19d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,16 +38,24 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_definitions(libfmio PRIVATE DEBUG=1) endif() -set(FM_LIBS inih libfmfilter libfmmodulation libfmio libfmdsp pulse pulse-simple m liquid) - foreach(SRC_FILE ${SRC_FILES}) get_filename_component(EXEC_NAME ${SRC_FILE} NAME_WE) add_executable(${EXEC_NAME} ${SRC_FILE}) target_compile_options(${EXEC_NAME} PRIVATE -O2 -Wall -Wextra -Werror -Wno-unused-parameter) - target_link_libraries(${EXEC_NAME} PRIVATE ${FM_LIBS}) - - # Define DEBUG macro for Debug builds + + if(EXEC_NAME STREQUAL "fm95") + target_link_libraries(${EXEC_NAME} PRIVATE libfmfilter libfmmodulation libfmdsp libfmio pulse pulse-simple m liquid inih) + elseif(EXEC_NAME STREQUAL "chimer95") + target_link_libraries(${EXEC_NAME} PRIVATE libfmdsp inih m libfmio pulse pulse-simple) + elseif(EXEC_NAME STREQUAL "sca95") + target_link_libraries(${EXEC_NAME} PRIVATE libfmmodulation inih m libfmio pulse pulse-simple libfmdsp) + elseif(EXEC_NAME STREQUAL "vban95") + target_link_libraries(${EXEC_NAME} PRIVATE libfmio pulse pulse-simple) + else() + message(FATAL_ERROR "How do I link this? ${EXEC_NAME}") + endif() + if(CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_definitions(${EXEC_NAME} PRIVATE DEBUG=1) endif() @@ -57,4 +65,4 @@ foreach(SRC_FILE ${SRC_FILES}) PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_WRITE GROUP_READ WORLD_EXECUTE WORLD_READ) -endforeach() \ No newline at end of file +endforeach() diff --git a/src/fm95.c b/src/fm95.c index 94e5d1b..704d784 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -102,12 +102,12 @@ static void stop(int signum) { (void)signum; printf("\nReceived stop signal.\n"); to_run = 0; - to_reload = 0; + to_reload = 0; // Make sure we don't reload } static void reload(int signum) { (void)signum; printf("\nReceived reload signal.\n"); - to_run = 0; + to_run = 0; // To run is a flag, just telling when to stop the loop to_reload = 1; } @@ -141,9 +141,10 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { bool mpx_on = (runtime->mpx_device.initialized == 1); bool rds_on = (runtime->rds_device.initialized == 1); + float output[BUFFER_SIZE]; + if(config.calibration != 0) { int pulse_error; - float output[BUFFER_SIZE]; while(to_run) { for (int i = 0; i < BUFFER_SIZE; i++) { @@ -166,7 +167,6 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { float audio_stereo_input[BUFFER_SIZE*2]; // Stereo float mpx_in[BUFFER_SIZE] = {0}; - float output[BUFFER_SIZE]; while (to_run) { if((pulse_error = read_PulseInputDevice(&runtime->input_device, audio_stereo_input, sizeof(audio_stereo_input)))) { // get output from the function and assign it into pulse_error, this comment to avoid confusion