Don't use env vars for configuration time options

- As a general rule of thumb one shouldn't use environment variables
  for setting configuration options for CMake. The reason for this is
  we don't know when CMake will be executed and re-evaluate that variable.
- e.g. If we run cmake a first time with a var set, and then run make on
  a second session (with no var) and cmake is called because a
  dependency changed, the option would be disabled
- This commit removes the use of environment vars from
  src/nvim/CMakeLists.txt entirely
- Removed SKIP_UNITTEST since it could only be used to remove a target
  at configuration time (and the target was optional anyway)
- Turned SANITIZE into an option, clang-asan.sh now passes cmake
  -DSANITIZE=ON
- Removed SKIP_EXEC since it was disabling a target at configuration time
  (not being used)
This commit is contained in:
Rui Abreu Ferreira 2014-12-01 10:25:40 +00:00
parent cb86eca91f
commit 923d021c0f
3 changed files with 10 additions and 16 deletions

View File

@ -25,18 +25,16 @@ symbolizer=/usr/local/clang-$clang_version/bin/llvm-symbolizer
setup_prebuilt_deps x64 setup_prebuilt_deps x64
export SANITIZE=1
export ASAN_SYMBOLIZER_PATH=$symbolizer export ASAN_SYMBOLIZER_PATH=$symbolizer
export ASAN_OPTIONS="detect_leaks=1:log_path=$tmpdir/asan" export ASAN_OPTIONS="detect_leaks=1:log_path=$tmpdir/asan"
export TSAN_OPTIONS="external_symbolizer_path=$symbolizer:log_path=$tmpdir/tsan" export TSAN_OPTIONS="external_symbolizer_path=$symbolizer:log_path=$tmpdir/tsan"
export SKIP_UNITTEST=1
export UBSAN_OPTIONS="log_path=$tmpdir/ubsan" # not sure if this works export UBSAN_OPTIONS="log_path=$tmpdir/ubsan" # not sure if this works
CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DUSE_GCOV=ON" CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DUSE_GCOV=ON"
# Build and output version info. # Build and output version info.
$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim $MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DSANITIZE=ON" nvim
build/bin/nvim --version build/bin/nvim --version
# Run functional tests. # Run functional tests.

View File

@ -94,8 +94,9 @@ endforeach()
set_source_files_properties( set_source_files_properties(
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion") ${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
option(SANITIZE "Enable sanitizers when using Clang" OFF)
if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(DEFINED ENV{SANITIZE}) if(SANITIZE)
message(STATUS "Enabling the sanitizers") message(STATUS "Enabling the sanitizers")
add_definitions(-DEXITFREE) # is this necessary for LeakSanitizer? add_definitions(-DEXITFREE) # is this necessary for LeakSanitizer?
add_definitions(-fno-sanitize-recover -fno-omit-frame-pointer add_definitions(-fno-sanitize-recover -fno-omit-frame-pointer
@ -200,17 +201,13 @@ list(APPEND NVIM_LINK_LIBRARIES
m m
${CMAKE_THREAD_LIBS_INIT}) ${CMAKE_THREAD_LIBS_INIT})
if(NOT DEFINED ENV{SKIP_EXEC}) add_executable(nvim ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES}
add_executable(nvim ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES} ${NEOVIM_HEADERS})
${NEOVIM_HEADERS}) target_link_libraries(nvim ${NVIM_LINK_LIBRARIES})
target_link_libraries(nvim ${NVIM_LINK_LIBRARIES}) install_helper(TARGETS nvim)
install_helper(TARGETS nvim)
endif()
if(NOT DEFINED ENV{SKIP_UNITTEST}) add_library(nvim-test MODULE EXCLUDE_FROM_ALL ${NEOVIM_GENERATED_SOURCES}
add_library(nvim-test MODULE EXCLUDE_FROM_ALL ${NEOVIM_GENERATED_SOURCES}
${NEOVIM_SOURCES} ${NEOVIM_HEADERS}) ${NEOVIM_SOURCES} ${NEOVIM_HEADERS})
target_link_libraries(nvim-test ${NVIM_LINK_LIBRARIES}) target_link_libraries(nvim-test ${NVIM_LINK_LIBRARIES})
endif()
add_subdirectory(po) add_subdirectory(po)

View File

@ -2,8 +2,7 @@ find_package(Gettext)
find_program(XGETTEXT_PRG xgettext) find_program(XGETTEXT_PRG xgettext)
find_program(ICONV_PRG iconv) find_program(ICONV_PRG iconv)
if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG AND if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
NOT DEFINED ENV{SKIP_EXEC})
set(ENV{OLD_PO_FILE_INPUT} yes) set(ENV{OLD_PO_FILE_INPUT} yes)
set(ENV{OLD_PO_FILE_OUTPUT} yes) set(ENV{OLD_PO_FILE_OUTPUT} yes)