Skip to content

Commit

Permalink
Force out of source builds
Browse files Browse the repository at this point in the history
ensure build directory exists in build script
let args be passed to debug.sh

Not you can call it like.
cd _build && ../debug.sh ..
  • Loading branch information
wwiv committed Jan 8, 2018
1 parent 1fd52d1 commit 5411624
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(Common)
include(FindASan)

MACRO_ENSURE_OUT_OF_SOURCE_BUILD()

if (WWIV_BUILD_TESTS)
# Workaround gtest really wanting to compile with /Mtd vs /MD
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand Down
4 changes: 4 additions & 0 deletions builds/jenkins/wwiv/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ build_binaries() {
popd > /dev/null

echo "Compiling Everything"
if [[ ! -d "${CMAKE_BUILD}" ]]; then
mkdir -p ${CMAKE_BUILD}
fi

pushd ${CMAKE_BUILD}
cmake -DCMAKE_BUILD_TYPE:STRING=Debug ..
cmake --build . -- ${make_args}
Expand Down
12 changes: 12 additions & 0 deletions cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ function(SET_WARNING_LEVEL_4)
endif()
endfunction()

MACRO(MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}"
"${${PROJECT_NAME}_BINARY_DIR}" insource)
GET_FILENAME_COMPONENT(PARENTDIR ${${PROJECT_NAME}_SOURCE_DIR} PATH)
STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}"
"${PARENTDIR}" insourcesubdir)
IF(insource OR insourcesubdir)
MESSAGE(FATAL_ERROR "${PROJECT_NAME} requires an out of source build.")
ENDIF(insource OR insourcesubdir)
ENDMACRO(MACRO_ENSURE_OUT_OF_SOURCE_BUILD)


message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
3 changes: 2 additions & 1 deletion debug.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
declare -r OS=$(uname)
echo "$(pwd)"

if [[ "${OS}" == "SunOS" ]]; then
echo "Setting compiler to gcc for SunOS"
export CXX=/usr/bin/g++
export CC=/usr/bin/gcc
fi

cmake -DCMAKE_BUILD_TYPE:STRING=Debug
cmake -DCMAKE_BUILD_TYPE:STRING=Debug $@

0 comments on commit 5411624

Please sign in to comment.