Skip to content

Commit

Permalink
Merge pull request #697 from zdenop/cmake_C17
Browse files Browse the repository at this point in the history
cmake improvements
  • Loading branch information
zdenop committed May 27, 2023
2 parents a7b5bc2 + 9199e62 commit 5e74433
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets")

project(
leptonica
LANGUAGES C CXX
LANGUAGES C
VERSION 1.84.0)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Standard installation paths
include(GNUInstallDirs)

set(MINIMUM_WEBPMUX_VERSION 0.5.0)

Expand Down
8 changes: 5 additions & 3 deletions prog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
########################################
function(add_prog_target target)
set (${target}_src "${ARGN}")
if (WIN32)
set_source_files_properties (${${target}_src} PROPERTIES LANGUAGE CXX)
endif()
add_executable (${target} ${${target}_src})
string(FIND ${target} "gif" GIF_TEST_FOUND)
if (GIF_TEST_FOUND EQUAL 0)
# gif_lib.h is not found on Windows
target_include_directories (${target} PRIVATE ${GIF_INCLUDE_DIR})
endif()
if (BUILD_SHARED_LIBS)
target_compile_definitions (${target} PRIVATE -DLIBLEPT_IMPORTS)
endif()
Expand Down
7 changes: 4 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

file(GLOB hdr "*.h")
file(GLOB src "*.c")
if (MSVC)
set_source_files_properties(${src} PROPERTIES LANGUAGE CXX)
endif()

string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")

Expand Down Expand Up @@ -73,6 +70,10 @@ if (UNIX)
endif(SYM_LINK)
endif()

if (MSVC)
target_link_libraries (leptonica PRIVATE user32.lib gdi32.lib)
endif()

if (NOT SW_BUILD)
export(TARGETS leptonica FILE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake)
else()
Expand Down

0 comments on commit 5e74433

Please sign in to comment.