From 771ece92d3bad54555665a4ea663fc91224a6de9 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 13 Feb 2024 11:33:09 -0500 Subject: Set compiler flags specific compilers --- CMakeLists.txt | 14 ++++++++++++++ src/CMakeLists.txt | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d74920..42b78ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,22 @@ cmake_minimum_required(VERSION 3.15) project(OMC C) include(GNUInstallDirs) +set(nix_cflags -Wall -Wextra) +set(win_cflags /Wall) set(CMAKE_C_STANDARD 99) + link_libraries(curl) + +if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + message("gnu options") + add_compile_options(${nix_cflags}) +elseif (CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options(${nix_cflags}) +elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC") + message("microsoft visual c options") + add_compile_options(${win_cflags}) +endif() + add_subdirectory(src) set(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90219ac..4b0d99a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories(${CMAKE_BINARY_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${PROJECT_BINARY_DIR}) -add_compile_options(-Wall -Wextra -Wno-format-truncation) + add_executable(omc main.c str.c @@ -21,4 +21,4 @@ add_executable(omc template.c rules.c ) -install(TARGETS omc RUNTIME) \ No newline at end of file +install(TARGETS omc RUNTIME) -- cgit