From a50af55582be2fd35b445d58092940c0c8e13fff Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Tue, 2 Mar 2021 11:55:41 +0100 Subject: [PATCH] Do NOT set visibility to hidden for all targets only if requested and only for our target use clang-tidy too on CI on cmacos --- .clang-tidy | 2 +- .github/workflows/macos.yml | 4 ++++ .github/workflows/standalone.yml | 2 ++ CMakeLists.txt | 23 +++++++++++++++-------- GNUmakefile | 5 +++-- cmake/CPM.cmake | 2 +- cmake/options.cmake | 4 ---- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 56b09c7..ec940f6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,7 +6,7 @@ clang-analyzer-*,\ cppcoreguidelines-*,\ -cppcoreguidelines-macro-usage,\ -cppcoreguidelines-owning-memory,\ --hicpp-*,\ +hicpp-*,\ misc-*,\ -misc-non-private-member-variables-in-classes,\ -modernize-*,\ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index bbe6b24..5d84cf9 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -37,3 +37,7 @@ jobs: run: | cd build ctest --build-config Debug + + - name: build standalone with clang-tidy + run: | + cmake -S standalone -B build/standalone -DUSE_STATIC_ANALYZER=clang-tidy diff --git a/.github/workflows/standalone.yml b/.github/workflows/standalone.yml index ca2d2f1..ed0288b 100644 --- a/.github/workflows/standalone.yml +++ b/.github/workflows/standalone.yml @@ -4,9 +4,11 @@ name: Standalone on: push: branches: + - master - develop pull_request: branches: + - master - develop env: diff --git a/CMakeLists.txt b/CMakeLists.txt index c380a18..054e64b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,18 +52,25 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS source/*.cpp) add_library(Greeter ${headers} ${sources}) set_target_properties(Greeter PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD}) -# for SameMajorVersion upgrade stategie -set_target_properties(Greeter PROPERTIES SOVERSION 1 VERSION ${PROJECT_VERSION}) +# Note: for SameMajorVersion upgrade stategie +set_target_properties( + Greeter + PROPERTIES SOVERSION 1 + VERSION ${PROJECT_VERSION} + VISIBILITY_INLINES_HIDDEN ${BUILD_SHARED_LIBS} + CMAKE_VISIBILITY_INLINES_HIDDEN ${BUILD_SHARED_LIBS} +) # being a cross-platform target, we enforce standards conformance on MSVC -target_compile_options(Greeter PUBLIC "$<$:/permissive>") +target_compile_options(Greeter PUBLIC $<$:/permissive>) -# Link dependencies, but Note: the fmt lib does not work with SHARED yet! CK -target_link_libraries(Greeter PUBLIC fmt::fmt-header-only) +# Link dependencies +target_link_libraries(Greeter PUBLIC $) +# XXX target_link_libraries(Greeter PUBLIC fmt::fmt) set(INCLUDE_INSTALL_DIR include/${PROJECT_NAME}-${PROJECT_VERSION}) target_include_directories( - Greeter BEFORE PUBLIC $ + Greeter BEFORE PUBLIC $ $ ) @@ -89,7 +96,7 @@ packageProject( BINARY_DIR ${PROJECT_BINARY_DIR} INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include INCLUDE_DESTINATION ${INCLUDE_INSTALL_DIR} - VERSION_HEADER "${VERSION_HEADER_LOCATION}" + VERSION_HEADER ${VERSION_HEADER_LOCATION} COMPATIBILITY SameMajorVersion - DEPENDENCIES "fmt 7.1.3" + # XXX DEPENDENCIES "fmt 7.1.3" ) diff --git a/GNUmakefile b/GNUmakefile index edf5402..951eb5c 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -44,7 +44,7 @@ test: install # all together all: test - cmake -S $@ -B build/$@ -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${ROOT} -DTEST_INSTALLED_VERSION=1 -DENABLE_TEST_COVERAGE=1 + cmake -S $@ -B build/$@ -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${ROOT} -DTEST_INSTALLED_VERSION=1 -DENABLE_TEST_COVERAGE=1 -DUSE_STATIC_ANALYZER=clang-tidy cmake --build build/$@ cmake --build build/$@ --target test cmake --build build/$@ --target check-format @@ -66,4 +66,5 @@ standalone: # check the library check: standalone - run-clang-tidy.py -p build/standalone -checks='-*,modernize-*,misc-*,hicpp-*,cert-*,readability-*,portability-*,performance-*,google-*' standalone + run-clang-tidy.py -p build/standalone standalone + # TODO builddriver run-clang-tidy.py -p build/standalone -checks='-*,modernize-*,misc-*,hicpp-*,cert-*,readability-*,portability-*,performance-*,google-*' standalone diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 291e30e..f777eb0 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -1,4 +1,4 @@ -set(CPM_DOWNLOAD_VERSION 0.31.0) +set(CPM_DOWNLOAD_VERSION 0.31.1) if(CPM_SOURCE_CACHE) # Expand relative path. This is important if the provided path contains a tilde (~) diff --git a/cmake/options.cmake b/cmake/options.cmake index 8650052..0bd4e33 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -5,10 +5,6 @@ endif() option(BUILD_SHARED_LIBS "Create shared libraries" YES) -# Set default visibility to hidden for all targets -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) - # build the dynamic libraries and executables together at bin directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)