From a864b6ab55f73b5bcaebb75830b7f7b6c42d29ab Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sun, 18 Mar 2018 16:56:14 +0300 Subject: [PATCH] [C] Changed build options --- .travis.yml | 8 ++++---- CMakeLists.txt | 32 +++++++++++++++++++------------- README.md | 2 +- appveyor.yml | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec671ea..8e96138 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ matrix: - os: linux sudo: false compiler: gcc - env: GCC_BUILD=ON + env: FORT_COMPILER=gcc before_script: - pip install --user cpp-coveralls after_success: @@ -12,7 +12,7 @@ matrix: - os: linux sudo: required # to prevent fail of executables build with clang and sanitizers compiler: clang - env: GCC_BUILD=OFF + env: FORT_COMPILER=clang @@ -28,7 +28,7 @@ script: # Test build without optimizations - mkdir -p build - cd build - - cmake .. -DFORT_BUILD_TYPE=asan -DFORT_GCC_BUILD=${GCC_BUILD} + - cmake .. -DFORT_BUILD_TYPE=asan -DFORT_COMPILER=${FORT_COMPILER} - cmake --build . --target all - ls - ./libfort_example @@ -40,7 +40,7 @@ script: cd .. ; rm -r build/* ; cd build ; - cmake .. -DFORT_COVERALLS_BUILD=ON -DFORT_BUILD_TYPE=asan -DFORT_GCC_BUILD=${GCC_BUILD} ; + cmake .. -DFORT_COVERALLS_BUILD=ON -DFORT_BUILD_TYPE=asan -DFORT_COMPILER=${FORT_COMPILER} ; cmake --build . --target all ; ls ; ./libfort_test ; diff --git a/CMakeLists.txt b/CMakeLists.txt index d6ece8e..7afc734 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,12 @@ project(libfort) cmake_minimum_required(VERSION 2.8) # Built options -option(FORT_GCC_BUILD "Build with gcc" ON) -option(FORT_MSVC_BUILD "Build with msvc" OFF) +#option(FORT_GCC_BUILD "Build with gcc" ON) +#option(FORT_MSVC_BUILD "Build with msvc" OFF) option(FORT_CXX_BUILD "Compile with c++ compiler instead of c" OFF) option(FORT_COVERALLS_BUILD "Build for coveralls" OFF) set(FORT_BUILD_TYPE "common" CACHE STRING "Built types (possible values: common, asan, ubsan, msan)") +set(FORT_COMPILER "gcc" CACHE STRING "Compiler (possible values: gcc, clang, msvc)") @@ -20,13 +21,18 @@ include_directories(src) # Turn on warnings -if(FORT_MSVC_BUILD) +#if(FORT_MSVC_BUILD) +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4") +#else(FORT_MSVC_BUILD) +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g") +#endif(FORT_MSVC_BUILD) + + +if(FORT_COMPILER STREQUAL "msvc") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4") -else(FORT_MSVC_BUILD) +else(FORT_COMPILER STREQUAL "msvc") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g") -endif(FORT_MSVC_BUILD) - - +endif(FORT_COMPILER STREQUAL "msvc") @@ -76,24 +82,24 @@ endif(FORT_CXX_BUILD) # Adding sanitizers -if(NOT FORT_MSVC_BUILD) +if(FORT_COMPILER STREQUAL "gcc" OR FORT_COMPILER STREQUAL "clang") if(FORT_BUILD_TYPE STREQUAL "asan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") - if(FORT_GCC_BUILD) + if(FORT_COMPILER STREQUAL "gcc") target_link_libraries(${PROJECT_NAME}_example asan) target_link_libraries(${PROJECT_NAME}_test asan) - endif(FORT_GCC_BUILD) + endif(FORT_COMPILER STREQUAL "gcc") endif(FORT_BUILD_TYPE STREQUAL "asan") if(FORT_BUILD_TYPE STREQUAL "ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover") #to force fail - if(FORT_GCC_BUILD) + if(FORT_COMPILER STREQUAL "gcc") target_link_libraries(${PROJECT_NAME}_example ubsan) target_link_libraries(${PROJECT_NAME}_test ubsan) - endif(FORT_GCC_BUILD) + endif(FORT_COMPILER STREQUAL "gcc") endif(FORT_BUILD_TYPE STREQUAL "ubsan") -endif(NOT FORT_MSVC_BUILD) +endif(FORT_COMPILER STREQUAL "gcc" OR FORT_COMPILER STREQUAL "clang") # Coveralls support diff --git a/README.md b/README.md index 0c747c5..89fdc39 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # libfort (WIP - work in progress) -