aboutsummaryrefslogtreecommitdiffstats
path: root/gulrak-filesystem/cmake
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:13 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:13 -0500
commitbeb08eb751fa8e1f72042f263316ab5e5ddb596d (patch)
tree3b00df983527648bdae610ac7b88cb639b1f1828 /gulrak-filesystem/cmake
parentfbc30002ab3438356c0476e70c4577a0310d52c0 (diff)
New upstream version 2.4.0+dfsg.upstream/2.4.0+dfsgupstream
Diffstat (limited to 'gulrak-filesystem/cmake')
-rw-r--r--gulrak-filesystem/cmake/GhcHelper.cmake64
-rw-r--r--gulrak-filesystem/cmake/config.cmake.in6
2 files changed, 70 insertions, 0 deletions
diff --git a/gulrak-filesystem/cmake/GhcHelper.cmake b/gulrak-filesystem/cmake/GhcHelper.cmake
new file mode 100644
index 0000000..8fffae9
--- /dev/null
+++ b/gulrak-filesystem/cmake/GhcHelper.cmake
@@ -0,0 +1,64 @@
+macro(AddExecutableWithStdFS targetName)
+
+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))
+ if(APPLE)
+ include_directories(/usr/local/opt/llvm/include)
+ link_directories(/usr/local/opt/llvm/lib)
+ endif()
+ add_executable(${targetName} ${ARGN})
+ set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+ if(APPLE)
+ target_link_libraries(${targetName} -lc++fs)
+ else()
+ target_compile_options(${targetName} PRIVATE "-stdlib=libc++")
+ target_link_libraries(${targetName} -stdlib=libc++ -lc++fs $<$<PLATFORM_ID:Linux>:rt>)
+ endif()
+ else()
+ if(NOT APPLE)
+ target_compile_options(${targetName} PRIVATE "-stdlib=libc++")
+ target_link_libraries(${targetName} -stdlib=libc++)
+ endif()
+ endif()
+ target_compile_definitions(${targetName} PRIVATE USE_STD_FS)
+endif()
+
+if (CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 8.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0))
+ add_executable(${targetName} ${ARGN})
+ set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+ target_link_libraries(${targetName} -lstdc++fs)
+ endif()
+ target_compile_options(${targetName} PRIVATE $<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
+ target_compile_definitions(${targetName} PRIVATE USE_STD_FS)
+endif()
+
+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))
+ add_executable(${targetName} ${ARGN})
+ set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17)
+ set_property(TARGET ${targetName} PROPERTY CXX_STANDARD_REQUIRED ON)
+ target_compile_options(${targetName} PRIVATE "/Zc:__cplusplus")
+ target_compile_definitions(${targetName} PRIVATE USE_STD_FS _CRT_SECURE_NO_WARNINGS)
+endif()
+
+endmacro()
+
+macro(AddTestExecutableWithStdCpp cppStd)
+ add_executable(filesystem_test_cpp${cppStd} ${ARGN})
+ set_property(TARGET filesystem_test_cpp${cppStd} PROPERTY CXX_STANDARD ${cppStd})
+ target_link_libraries(filesystem_test_cpp${cppStd} ghc_filesystem)
+ target_compile_options(filesystem_test_cpp${cppStd} PRIVATE
+ $<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
+ $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-error=deprecated-declarations>
+ $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror -Wno-error=deprecated-declarations>
+ $<$<CXX_COMPILER_ID:MSVC>:/WX /wd4996>
+ $<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>
+ $<$<BOOL:${GHC_COVERAGE}>:--coverage>)
+ if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
+ target_compile_definitions(filesystem_test_cpp${cppStd} PRIVATE _CRT_SECURE_NO_WARNINGS)
+ endif()
+ if(EMSCRIPTEN)
+ set_target_properties(filesystem_test_cpp${cppStd} PROPERTIES LINK_FLAGS "-g4 -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1")
+ endif()
+ ParseAndAddCatchTests(filesystem_test_cpp${cppStd})
+endmacro()
diff --git a/gulrak-filesystem/cmake/config.cmake.in b/gulrak-filesystem/cmake/config.cmake.in
new file mode 100644
index 0000000..ace9761
--- /dev/null
+++ b/gulrak-filesystem/cmake/config.cmake.in
@@ -0,0 +1,6 @@
+@PACKAGE_INIT@
+
+# import targets
+include("${CMAKE_CURRENT_LIST_DIR}/ghc_filesystem-targets.cmake")
+
+check_required_components(ghcfilesystem) \ No newline at end of file