[C] Changed build options

This commit is contained in:
seleznevae 2018-03-18 16:56:14 +03:00
parent 913432d67b
commit a864b6ab55
4 changed files with 25 additions and 19 deletions

View File

@ -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 ;

View File

@ -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

View File

@ -1,11 +1,11 @@
# libfort (WIP - work in progress)
<!---
[![Build Status](https://travis-ci.org/seleznevae/libfort.svg?branch=master)](https://travis-ci.org/seleznevae/libfort)
[![Build status](https://ci.appveyor.com/api/projects/status/ll1qygb56pho95xw/branch/master?svg=true)](https://ci.appveyor.com/project/seleznevae/libfort/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/seleznevae/libfort/badge.svg?branch=master)](https://coveralls.io/github/seleznevae/libfort?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<!---
## Supported platforms and compilers
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/seleznevae/libfort) and [AppVeyor](https://ci.appveyor.com/project/seleznevae/libfort):

View File

@ -14,7 +14,7 @@ install:
before_build:
- mkdir build
- cd build
- cmake -G "Visual Studio 15 2017 Win64" .. -DFORT_TEST_BUILD=OFF -DFORT_GCC_BUILD=OFF -DFORT_MSVC_BUILD=ON
- cmake -G "Visual Studio 15 2017 Win64" .. -DFORT_COMPILER=msvc
- dir
build: