Skip to content

Commit

Permalink
fix fmt on linux clang (#412)
Browse files Browse the repository at this point in the history
* fix fmt on linux clang

* fix apple condition
  • Loading branch information
cieslarmichal authored Jan 3, 2024
1 parent 3f8df54 commit a610aed
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(BUILD_FAKER_TESTS DEFAULT ON)

if(MSVC)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /permissive- /bigobj")
else()
else ()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion -Wformat -Werror"
)
endif()
endif ()

set(LIBRARY_NAME faker-cxx)

Expand Down Expand Up @@ -113,15 +113,13 @@ target_include_directories(
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include"
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")

if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
add_subdirectory(externals/fmt)
set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include")
target_link_libraries(${LIBRARY_NAME} PRIVATE fmt)
endif()
endif ()

if(BUILD_FAKER_TESTS)
if (BUILD_FAKER_TESTS)
add_subdirectory(externals/googletest)

set(GTEST_INCLUDE_DIR
Expand All @@ -140,26 +138,24 @@ if(BUILD_FAKER_TESTS)
add_executable(${LIBRARY_NAME}-UT ${FAKER_UT_SOURCES})

target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main
faker-cxx)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
faker-cxx)
if (APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})
${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})

else()
else ()
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR})
endif()
${CMAKE_CURRENT_LIST_DIR})
endif ()

add_test(
NAME ${LIBRARY_NAME}-UT
COMMAND ${LIBRARY_NAME}-UT
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

target_code_coverage(${LIBRARY_NAME}-UT ALL)
endif()
endif ()

0 comments on commit a610aed

Please sign in to comment.