Skip to content

Commit

Permalink
CMake: Do not compile/use included "getopt" if OS has native implemen…
Browse files Browse the repository at this point in the history
…tation. (#163)

* Only compile getopt if no native implementation found.
  • Loading branch information
tjko committed Oct 30, 2023
1 parent a200b97 commit 02d322b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -280,6 +286,12 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
)


# Include getopt only if no native implementation found.
if(NOT HAVE_GETOPT_LONG)
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)
Expand Down

0 comments on commit 02d322b

Please sign in to comment.