| 1 |
macro(AddExecutableWithStdFS targetName) |
| 2 |
|
| 3 |
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)) |
| 4 |
if(APPLE) |
| 5 |
include_directories(/usr/local/opt/llvm/include) |
| 6 |
link_directories(/usr/local/opt/llvm/lib) |
| 7 |
endif() |
| 8 |
add_executable(${targetName} ${ARGN}) |
| 9 |
set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17) |
| 10 |
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) |
| 11 |
if(APPLE) |
| 12 |
target_link_libraries(${targetName} -lc++fs) |
| 13 |
else() |
| 14 |
target_compile_options(${targetName} PRIVATE "-stdlib=libc++") |
| 15 |
target_link_libraries(${targetName} -stdlib=libc++ -lc++fs $<$<PLATFORM_ID:Linux>:rt>) |
| 16 |
endif() |
| 17 |
else() |
| 18 |
if(NOT APPLE) |
| 19 |
target_compile_options(${targetName} PRIVATE "-stdlib=libc++") |
| 20 |
target_link_libraries(${targetName} -stdlib=libc++) |
| 21 |
endif() |
| 22 |
endif() |
| 23 |
target_compile_definitions(${targetName} PRIVATE USE_STD_FS) |
| 24 |
endif() |
| 25 |
|
| 26 |
if (CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 8.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)) |
| 27 |
add_executable(${targetName} ${ARGN}) |
| 28 |
set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17) |
| 29 |
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) |
| 30 |
target_link_libraries(${targetName} -lstdc++fs) |
| 31 |
endif() |
| 32 |
target_compile_options(${targetName} PRIVATE $<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>) |
| 33 |
target_compile_definitions(${targetName} PRIVATE USE_STD_FS) |
| 34 |
endif() |
| 35 |
|
| 36 |
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 19.15 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.15)) |
| 37 |
add_executable(${targetName} ${ARGN}) |
| 38 |
set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17) |
| 39 |
set_property(TARGET ${targetName} PROPERTY CXX_STANDARD_REQUIRED ON) |
| 40 |
target_compile_options(${targetName} PRIVATE "/Zc:__cplusplus") |
| 41 |
target_compile_definitions(${targetName} PRIVATE USE_STD_FS _CRT_SECURE_NO_WARNINGS) |
| 42 |
endif() |
| 43 |
|
| 44 |
endmacro() |
| 45 |
|
| 46 |
macro(AddTestExecutableWithStdCpp cppStd) |
| 47 |
add_executable(filesystem_test_cpp${cppStd} ${ARGN}) |
| 48 |
set_property(TARGET filesystem_test_cpp${cppStd} PROPERTY CXX_STANDARD ${cppStd}) |
| 49 |
target_link_libraries(filesystem_test_cpp${cppStd} ghc_filesystem) |
| 50 |
target_compile_options(filesystem_test_cpp${cppStd} PRIVATE |
| 51 |
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0> |
| 52 |
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-error=deprecated-declarations> |
| 53 |
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror -Wno-error=deprecated-declarations> |
| 54 |
$<$<CXX_COMPILER_ID:MSVC>:/WX /wd4996> |
| 55 |
$<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj> |
| 56 |
$<$<BOOL:${GHC_COVERAGE}>:--coverage>) |
| 57 |
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) |
| 58 |
target_compile_definitions(filesystem_test_cpp${cppStd} PRIVATE _CRT_SECURE_NO_WARNINGS) |
| 59 |
endif() |
| 60 |
if(EMSCRIPTEN) |
| 61 |
set_target_properties(filesystem_test_cpp${cppStd} PROPERTIES LINK_FLAGS "-g4 -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1") |
| 62 |
endif() |
| 63 |
ParseAndAddCatchTests(filesystem_test_cpp${cppStd}) |
| 64 |
endmacro() |