summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--doc/userconfig-you@Clang.cmake99
-rw-r--r--run-show-coverage.sh89
3 files changed, 189 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7986654b..ec88ba64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,7 +53,7 @@ function(fm_load_userconfig)
set(_fm_userconfig "userconfig-${_fm_username}@${CMAKE_CXX_COMPILER_ID}.cmake")
if(EXISTS "${CMAKE_SOURCE_DIR}/${_fm_userconfig}")
message(STATUS "loading user config '${_fm_userconfig}'")
- include("${CMAKE_SOURCE_DIR}/${_fm_userconfig}")
+ include("${CMAKE_SOURCE_DIR}/${_fm_userconfig}" NO_POLICY_SCOPE)
else()
message(STATUS "user config '${_fm_userconfig}' not found")
endif()
diff --git a/doc/userconfig-you@Clang.cmake b/doc/userconfig-you@Clang.cmake
new file mode 100644
index 00000000..a8867da6
--- /dev/null
+++ b/doc/userconfig-you@Clang.cmake
@@ -0,0 +1,99 @@
+set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE)
+
+set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "" FORCE)
+
+sets(STRING
+ CMAKE_C_FLAGS ""
+ CMAKE_C_FLAGS_DEBUG "-O0 -g -glldb"
+ CMAKE_C_FLAGS_RELEASE "-O2 -mtune=native"
+)
+
+sets(STRING
+ CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}"
+ CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}"
+ CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}"
+)
+
+set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
+set(CMAKE_C_FLAGS_RELEASE "-O2 -mtune=native" CACHE STRING "" FORCE)
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
+set(CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
+set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
+
+add_compile_options(-emit-llvm)
+
+add_compile_options(-fdiagnostics-color=always)
+
+# for building submodule dependencies
+function(fm-userconfig-external-pre)
+ add_compile_options(
+ -Wno-ignored-attributes
+ -Wno-unused-function
+ -Wno-unused-but-set-variable
+ -Wno-old-style-cast
+ )
+endfunction()
+
+# for floormat sources only
+function(fm-userconfig-src)
+ add_compile_options(
+ -Wall -Wextra -Wpedantic -Wno-old-style-cast -Wno-padded
+ )
+ add_compile_options(
+ -Wall
+ -Wextra
+ -Wpedantic
+ -Weverything
+ -Wno-c++98-compat
+ -Wno-c++20-compat
+ -Wno-c++98-compat-pedantic
+ -Wno-undefined-func-template
+ -Wno-switch-enum
+ -Wno-covered-switch-default
+ -Wno-old-style-cast
+ -Wno-global-constructors
+ -Wno-exit-time-destructors
+ -Wno-implicit-int-float-conversion
+ -Wno-shadow-field-in-constructor
+ -Wno-shadow
+ -Wno-ctad-maybe-unsupported
+ -Wno-documentation-unknown-command
+ -Wno-documentation
+ -Wno-ignored-attributes
+ -Wno-reserved-identifier
+ )
+ add_compile_options(
+ -Werror
+ -Wno-error=float-equal # Magnum, floormat
+ -Wno-error=sign-conversion # Magnum
+ -Wno-error=reserved-identifier # Magnum, SDL2
+ -Wno-error=undef # SDL2
+ -Wno-error=missing-variable-declarations # Corrade
+ -Wno-error=comma # floormat
+ -Wno-error=unused-parameter # floormat
+ -Wno-error=unused-private-field # floormat
+ -Wno-suggest-destructor-override # Magnum
+ -Wno-error=alloca # floormat
+ )
+
+ if("$ENV{FLOORMAT_WITH_COVERAGE}")
+ add_definitions(
+ -fprofile-instr-generate
+ -fcoverage-mapping
+ -mllvm -runtime-counter-relocation=true
+ )
+ add_link_options(
+ -fprofile-instr-generate
+ -fcoverage-mapping
+ )
+ endif()
+endfunction()
+
+sets(BOOL
+ SDL_SHARED ON
+ SDL_STATIC OFF # speed up linking
+
+ #CORRADE_BUILD_TESTS TRUE
+ #MAGNUM_BUILD_TESTS TRUE
+)
+
diff --git a/run-show-coverage.sh b/run-show-coverage.sh
new file mode 100644
index 00000000..fe30785d
--- /dev/null
+++ b/run-show-coverage.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+set -e
+
+case "$OS" in
+ Windows_NT) export PATH="$PATH:/usr/bin" ;;
+esac
+
+self="$(basename -- "$1")"
+
+usage() {
+ echo "usage: ${self} <run|run-only|show|generate>" >&2
+ exit 64
+}
+
+if test -z "$1"; then
+ usage
+fi
+
+run=0
+generate=0
+show=0
+
+case "$1" in
+ run) run=1; generate=1; show=1 ;;
+ run-only) run=1 ;;
+ show) generate=1; show=1 ;;
+ generate) generate=1 ;;
+ *) echo "error: invalid command-line argument '$1'" >&2; usage ;;
+esac
+
+#find build directory
+if test -f CMakeLists.txt && test -f resources.conf; then
+ cd build
+elif test -d bin; then
+ cd ..
+elif test -x floormat || test -x floormat.exe; then
+ cd ../..
+elif test -d install/bin && test -d install/share/floormat; then
+ :
+else
+ echo "error: can't find build directory!" >&2
+ exit 65
+fi
+
+exe=
+for i in ./install/bin/floormat.exe ./install/bin/floormat; do
+ if test -x "$i"; then
+ exe="$i"
+ break
+ fi
+done
+
+if ! test -n "$exe"; then
+ echo "error: no 'floormat' executable" >&2
+ exit 65
+fi
+
+prof=coverage
+
+if test $run -gt 0; then
+ rm -f -- ./"${prof}".profraw ./"${prof}".profdata ../"${prof}".lcov
+ (
+ export FLOORMAT_WITH_COVERAGE=1
+ cmake .
+ cmake --build . --target install
+ )
+ LLVM_PROFILE_FILE="../${prof}.profraw" FLOORMAT_WITH_COVERAGE=1 \
+ "$exe" --magnum-gpu-validation on
+fi
+
+if test $generate -gt 0; then
+ llvm-profdata merge -sparse "./${prof}".profraw -o "./${prof}".profdata
+ llvm-cov export --format=lcov --instr-profile="./${prof}".profdata -- "$exe" > "./${prof}".lcov
+ if test -e "./${prof}"; then
+ rm -rf -- "./${prof}/"
+ fi
+ genhtml -o "./${prof}" -s "./${prof}.lcov"
+fi
+
+if test $show -gt 0; then
+ if command -v xdg-open >/dev/null; then
+ xdg-open "./${prof}/index.html"
+ else
+ start "./${prof}/index.html"
+
+ fi
+fi
+exit 0