]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Extract win32-compatibility stuff to a separate library
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Mar 2024 20:00:06 +0000 (21:00 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 27 Apr 2024 08:14:29 +0000 (10:14 +0200)
LICENSE.adoc
src/ccache/CMakeLists.txt
src/third_party/CMakeLists.txt
src/third_party/win32-compat/CMakeLists.txt [new file with mode: 0644]
src/third_party/win32-compat/win32/getopt.c [moved from src/third_party/win32/getopt.c with 100% similarity]
src/third_party/win32-compat/win32/getopt.h [moved from src/third_party/win32/getopt.h with 100% similarity]
src/third_party/win32-compat/win32/mktemp.c [moved from src/third_party/win32/mktemp.c with 100% similarity]
src/third_party/win32-compat/win32/mktemp.h [moved from src/third_party/win32/mktemp.h with 100% similarity]
src/third_party/win32-compat/win32/winerror_to_errno.h [moved from src/third_party/win32/winerror_to_errno.h with 100% similarity]

index 901bd7e7d63d5c43afb29a9f47405a89686ca68c..8c8210829a33d0ebe2cb82b9128d10f352dfb4d8 100644 (file)
@@ -613,7 +613,7 @@ express Statement of Purpose.
 ----
 
 
-=== src/third_party/win32/getopt.*
+=== src/third_party/win32-compat/win32/getopt.*
 
 This implementation of `getopt_long()` for Win32 was taken from
 https://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso
@@ -623,7 +623,7 @@ The full license text can be found in LGPL-3.0.txt and at
 https://www.gnu.org/licenses/lgpl-3.0.html.
 
 
-=== src/third_party/win32/mktemp.*
+=== src/third_party/win32-compat/win32/mktemp.*
 
 This implementation of `mkstemp()` for Win32 was adapted from
 <https://github.com/openbsd/src/blob/99b791d14c0f1858d87a0c33b55880fb9b00be66/lib/libc/stdio/mktemp.c>
@@ -647,7 +647,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ----
 
 
-=== src/third_party/win32/winerror_to_errno.h
+=== src/third_party/win32-compat/win32/winerror_to_errno.h
 
 The implementation of `winerror_to_errno()` was adapted from
 <https://github.com/python/cpython/blob/1a79785e3e8fea80bcf6a800b45a04e06c787480/PC/errmap.h>
index 629a361733b03112ece5009ae7e5135ac136b9bd..ec5d105332ee7ec0ae39bbe6c207a2b4fae19a46 100644 (file)
@@ -59,6 +59,10 @@ target_link_libraries(
     Threads::Threads
 )
 
+if(WIN32)
+  target_link_libraries(ccache_framework PUBLIC win32_compat)
+endif()
+
 get_filename_component(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
 target_include_directories(ccache_framework PUBLIC ${CMAKE_BINARY_DIR} ${SRC_DIR})
 
index a3071d24e5022ccd81bce5828dcbb831a96c2578..afebb64fe3f908391ca8188f26cfb82b217d2d17 100644 (file)
@@ -1,18 +1,6 @@
 add_library(third_party STATIC xxhash.c)
 target_include_directories(third_party INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
 
-if(MSVC)
-  target_sources(third_party PRIVATE win32/getopt.c)
-  target_compile_definitions(third_party PUBLIC -DSTATIC_GETOPT)
-endif()
-
-if(WIN32)
-  target_sources(third_party PRIVATE win32/mktemp.c)
-endif ()
-
-file(GLOB headers *.h nonstd/*.hpp win32/*.h)
-target_sources(third_party PRIVATE ${headers})
-
 set(xxhdispatchtest [=[
 #include "xxh_x86dispatch.c"
 
@@ -44,10 +32,6 @@ target_include_directories(
 
 target_link_libraries(third_party PRIVATE standard_settings)
 
-if(WIN32)
-  target_link_libraries(third_party PRIVATE ws2_32)
-endif()
-
 # Silence warning from winbase.h due to /Zc:preprocessor.
 if(MSVC)
   target_compile_options(third_party PRIVATE /wd5105)
@@ -55,6 +39,7 @@ endif()
 
 add_subdirectory(blake3)
 add_subdirectory(cxxurl)
+add_subdirectory(win32-compat)
 
 if(NOT TARGET dep_cpphttplib)
   add_subdirectory(cpp-httplib)
diff --git a/src/third_party/win32-compat/CMakeLists.txt b/src/third_party/win32-compat/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c0455c2
--- /dev/null
@@ -0,0 +1,13 @@
+add_library(win32_compat STATIC EXCLUDE_FROM_ALL win32/mktemp.c)
+
+if(MSVC)
+  target_sources(win32_compat PRIVATE win32/getopt.c)
+  target_compile_definitions(win32_compat PUBLIC STATIC_GETOPT)
+endif()
+
+# Silence warning from winbase.h due to /Zc:preprocessor.
+if(MSVC)
+  target_compile_options(win32_compat PRIVATE /wd5105)
+endif()
+
+target_include_directories(win32_compat INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")