Skip to content

Commit

Permalink
Format cmake lists
Browse files Browse the repository at this point in the history
  • Loading branch information
bugdea1er committed Apr 28, 2024
1 parent 139500b commit b626be4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .cmake-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tab_size = 4
max_lines_hwrap = 0
20 changes: 14 additions & 6 deletions cmake/FindFilesystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ cmake_push_check_state()

set(CMAKE_REQUIRED_QUIET TRUE)
set(CMAKE_REQUIRED_FLAGS -std=c++17)
set(Filesystem_TEST_SOURCE "
set(Filesystem_TEST_SOURCE
"
#include <filesystem>
#include <iostream>
int main() {
Expand All @@ -47,13 +48,15 @@ if(STD_FILESYSTEM_NO_LINK)
set(STD_FILESYSTEM_FOUND TRUE)
else()
set(CMAKE_REQUIRED_LIBRARIES -lstdc++fs)
check_cxx_source_compiles("${Filesystem_TEST_SOURCE}" STD_FILESYSTEM_STDCXXFS)
check_cxx_source_compiles(
"${Filesystem_TEST_SOURCE}" STD_FILESYSTEM_STDCXXFS)
if(STD_FILESYSTEM_STDCXXFS)
set(STD_FILESYSTEM_FOUND TRUE)
set(STD_FILESYSTEM_LIBRARY stdc++fs)
else()
set(CMAKE_REQUIRED_LIBRARIES -lc++fs)
check_cxx_source_compiles("${Filesystem_TEST_SOURCE}" STD_FILESYSTEM_CXXFS)
check_cxx_source_compiles(
"${Filesystem_TEST_SOURCE}" STD_FILESYSTEM_CXXFS)
if(STD_FILESYSTEM_STDCXXFS)
set(STD_FILESYSTEM_FOUND TRUE)
set(STD_FILESYSTEM_LIBRARY c++fs)
Expand All @@ -63,12 +66,17 @@ endif()

cmake_pop_check_state()

set(Filesystem_FOUND ${STD_FILESYSTEM_FOUND} CACHE BOOL "True if filesystem utilities are found")
set(Filesystem_LIBRARIES ${STD_FILESYSTEM_LIBRARY} CACHE STRING "The filesystem utilities libraries")
set(Filesystem_FOUND
${STD_FILESYSTEM_FOUND}
CACHE BOOL "True if filesystem utilities are found")
set(Filesystem_LIBRARIES
${STD_FILESYSTEM_LIBRARY}
CACHE STRING "The filesystem utilities libraries")
mark_as_advanced(STD_FILESYSTEM_FOUND STD_FILESYSTEM_LIBRARY)

if(Filesystem_LIBRARIES)
find_package_handle_standard_args(Filesystem DEFAULT_MSG Filesystem_LIBRARIES)
find_package_handle_standard_args(
Filesystem DEFAULT_MSG Filesystem_LIBRARIES)
else()
find_package_handle_standard_args(Filesystem DEFAULT_MSG Filesystem_FOUND)
endif()
Expand Down
10 changes: 6 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ endif()
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
)
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

add_executable(${PROJECT_NAME} file_test.cpp directory_test.cpp)
target_link_libraries(${PROJECT_NAME} tmp::tmp GTest::gtest_main)
target_compile_definitions(${PROJECT_NAME} PRIVATE PREFIX="com.github.bugdea1er.tmp")
target_compile_definitions(
${PROJECT_NAME} PRIVATE PREFIX="com.github.bugdea1er.tmp")

include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME})

0 comments on commit b626be4

Please sign in to comment.