Skip to content

Commit

Permalink
Don't compile yarn sources when threading is disabled in pigz CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Jun 4, 2021
1 parent 37c91f8 commit bfe54f2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/pigz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8.0)
add_definitions(-fno-diagnostics-show-caret)
endif()
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
elseif(WIN32)
add_definitions(-D_TIMESPEC_DEFINED)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
endif()

# Fetch pigz source code from official repository
Expand All @@ -59,21 +62,17 @@ endif()

set(PIGZ_SRCS
${pigz_SOURCE_DIR}/pigz.c
${pigz_SOURCE_DIR}/try.c
${pigz_SOURCE_DIR}/yarn.c)
${pigz_SOURCE_DIR}/try.c)

set(PIGZ_HDRS
${pigz_SOURCE_DIR}/try.h
${pigz_SOURCE_DIR}/yarn.h)
${pigz_SOURCE_DIR}/try.h)

add_executable(${PROJECT_NAME} ${PIGZ_SRCS} ${PIGZ_HDRS})
add_definitions(-DNOZOPFLI)

# Find and link against pthreads or pthreads4w
if(WITH_THREADS)
# Find and link against pthreads or pthreads4w
if(WIN32)
add_definitions(-D_TIMESPEC_DEFINED)

if(DEFINED PTHREADS4W_ROOT)
set(CLEANUP_STYLE VC)
set(PTHREADS4W_VERSION 3)
Expand All @@ -82,7 +81,7 @@ if(WITH_THREADS)
target_link_libraries(${PROJECT_NAME} pthreadVC3)
target_include_directories(${PROJECT_NAME} PRIVATE win ${PTHREADS4W_ROOT})
else()
message(WARNING "Missing pthreads4w root directory, disabling threading")
message(WARNING "Missing pthreads4w root directory")
set(WITH_THREADS OFF)
endif()
else()
Expand All @@ -97,6 +96,9 @@ endif()
# Disable threading support
if(NOT WITH_THREADS)
add_definitions(-DNOTHREAD)
else()
set_property(TARGET ${PROJECT_NAME} PROPERTY SOURCES APPEND
${pigz_SOURCE_DIR}/yarn.c ${pigz_SOURCE_DIR}/yarn.h)
endif()

# Find and link against zlib
Expand Down

0 comments on commit bfe54f2

Please sign in to comment.