From 720cecfc7e628d8952f0fa16da9c063613003cbc Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sun, 29 Oct 2023 18:12:47 -0700 Subject: [PATCH] Only compile getopt if no native implementation found. --- CMakeLists.txt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2798b6a..da8094f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,13 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Source groups -file(GLOB SOURCE_FILES *.c) +set(SOURCE_FILES + jpegoptim.c + jpegsrc.c + jpegdest.c + jpegmarker.c + misc.c + ) source_group("Source Files" FILES ${SOURCE_FILES}) @@ -146,9 +152,9 @@ endif() # Include directories -target_include_directories(${PROJECT_NAME} PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}" -) +#target_include_directories(${PROJECT_NAME} PUBLIC +# "${CMAKE_CURRENT_SOURCE_DIR}" +#) # Compile definitions @@ -280,6 +286,12 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE ) +# Include getopt only if no native implementation found. +if(!HAVE_GETOPT) + target_sources(${PROJECT_NAME} PRIVATE getopt.c getopt1.c) +endif() + + # Attach a manifest file to support UTF-8 on compatible Windows systems (see https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page) if(MSVC)