Skip to content

Commit 1d1baf5

Browse files
authored
Merge pull request #1495 from ggbecker/fix-windows-build-on-fresh-appveyor-maint_1-3
Use pthread required package when building on Windows.
2 parents 4da2378 + 3b8049d commit 1d1baf5

File tree

4 files changed

+20
-239
lines changed

4 files changed

+20
-239
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,16 @@ find_package(LibXslt REQUIRED)
143143
find_package(BZip2)
144144

145145
# PThread
146+
if (WIN32)
147+
find_package(ZLIB REQUIRED)
148+
find_package(pthread CONFIG REQUIRED)
149+
set(CMAKE_THREAD_LIBS_INIT ${PThreads4W_LIBRARY})
150+
else()
151+
find_package(Threads REQUIRED)
152+
endif()
146153
set(CMAKE_THREAD_PREFER_PTHREAD)
147154
set(THREADS_PREFER_PTHREAD_FLAG)
148-
set(THREADS_USE_PTHREADS_WIN32 true)
149-
find_package(Threads REQUIRED)
155+
set(THREADS_USE_PTHREADS_WIN32 TRUE)
150156
check_library_exists(pthread pthread_timedjoin_np "" HAVE_PTHREAD_TIMEDJOIN_NP)
151157
check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
152158
check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ image: Visual Studio 2017
77
configuration: Release
88
clone_folder: c:\projects\openscap
99
install:
10-
- cmd: vcpkg install curl libxml2 libxslt bzip2 pcre pthreads
10+
- cmd: vcpkg install curl libxml2 libxslt bzip2 pcre pthreads zlib getopt-win32
1111
cache: c:\tools\vcpkg\installed\
1212
before_build:
1313
- cmd: >-

cmake/FindThreads.cmake

Lines changed: 0 additions & 236 deletions
This file was deleted.

utils/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ if(ENABLE_OSCAP_UTIL)
1010
add_executable(oscap ${UTILS_SOURCES})
1111
target_link_libraries(oscap openscap)
1212
if(WIN32)
13+
find_path(GETOPT_INCLUDE_DIR getopt.h)
14+
include(SelectLibraryConfigurations)
15+
find_library(GETOPT_LIBRARY_RELEASE NAMES getopt)
16+
find_library(GETOPT_LIBRARY_DEBUG NAMES getopt PATH_SUFFIXES debug/lib)
17+
select_library_configurations(GETOPT)
18+
19+
message("GETOPT_INCLUDE_DIR: ${GETOPT_INCLUDE_DIR}")
20+
message("GETOPT_LIBRARY: ${GETOPT_LIBRARY}")
21+
22+
target_include_directories(oscap PRIVATE ${GETOPT_INCLUDE_DIR})
23+
target_link_libraries(oscap PRIVATE ${GETOPT_LIBRARY})
1324
set(OSCAP_UTIL_DESTINATION ".")
1425
# Install the 'oscap' utility
1526
install(TARGETS "oscap"

0 commit comments

Comments
 (0)