Unverified Commit 629515a8 by Patrick Steinhardt Committed by GitHub

Merge pull request #5481 from pks-t/pks/cmake-cleanups

CMake cleanups
parents 17641f1f 511fb9e6
...@@ -11,21 +11,12 @@ ...@@ -11,21 +11,12 @@
# Install: # Install:
# > cmake --build . --target install # > cmake --build . --target install
PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
CMAKE_POLICY(SET CMP0015 NEW)
IF(POLICY CMP0051) project(libgit2 C)
CMAKE_POLICY(SET CMP0051 NEW)
ENDIF()
IF(POLICY CMP0042)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF()
IF(POLICY CMP0054)
CMAKE_POLICY(SET CMP0054 NEW)
ENDIF()
# Add find modules to the path # Add find modules to the path
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
INCLUDE(CheckLibraryExists) INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists) INCLUDE(CheckFunctionExists)
...@@ -49,8 +40,6 @@ OPTION(THREADSAFE "Build libgit2 as threadsafe" ON) ...@@ -49,8 +40,6 @@ OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON) OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF) OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF) OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
OPTION(TAGS "Generate tags" OFF)
OPTION(PROFILE "Generate profiling information" OFF)
OPTION(ENABLE_TRACE "Enables tracing support" ON) OPTION(ENABLE_TRACE "Enables tracing support" ON)
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF) OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON) OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
...@@ -242,35 +231,27 @@ ELSE () ...@@ -242,35 +231,27 @@ ELSE ()
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1) ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
ENDIF () ENDIF ()
ENABLE_WARNINGS(documentation) enable_warnings(documentation)
DISABLE_WARNINGS(missing-field-initializers) disable_warnings(documentation-deprecated-sync)
ENABLE_WARNINGS(strict-aliasing) disable_warnings(missing-field-initializers)
ENABLE_WARNINGS(strict-prototypes) enable_warnings(strict-aliasing)
ENABLE_WARNINGS(declaration-after-statement) enable_warnings(strict-prototypes)
ENABLE_WARNINGS(shift-count-overflow) enable_warnings(declaration-after-statement)
ENABLE_WARNINGS(unused-const-variable) enable_warnings(shift-count-overflow)
ENABLE_WARNINGS(unused-function) enable_warnings(unused-const-variable)
ENABLE_WARNINGS(int-conversion) enable_warnings(unused-function)
enable_warnings(int-conversion)
# MinGW uses gcc, which expects POSIX formatting for printf, but # MinGW uses gcc, which expects POSIX formatting for printf, but
# uses the Windows C library, which uses its own format specifiers. # uses the Windows C library, which uses its own format specifiers.
# Disable format specifier warnings. # Disable format specifier warnings.
IF(MINGW) if(MINGW)
DISABLE_WARNINGS(format) disable_warnings(format)
DISABLE_WARNINGS(format-security) disable_warnings(format-security)
ELSE() else()
ENABLE_WARNINGS(format) enable_warnings(format)
ENABLE_WARNINGS(format-security) enable_warnings(format-security)
ENDIF() endif()
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
DISABLE_WARNINGS(documentation-deprecated-sync)
ENDIF()
IF (PROFILE)
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
ENDIF ()
ENDIF() ENDIF()
# Ensure that MinGW provides the correct header files. # Ensure that MinGW provides the correct header files.
...@@ -310,25 +291,6 @@ IF (BUILD_CLAR) ...@@ -310,25 +291,6 @@ IF (BUILD_CLAR)
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
ENDIF () ENDIF ()
IF (TAGS)
FIND_PROGRAM(CTAGS ctags)
IF (NOT CTAGS)
MESSAGE(FATAL_ERROR "Could not find ctags command")
ENDIF ()
FILE(GLOB_RECURSE SRC_ALL *.[ch])
ADD_CUSTOM_COMMAND(
OUTPUT tags
COMMAND ${CTAGS} -a ${SRC_ALL}
DEPENDS ${SRC_ALL}
)
ADD_CUSTOM_TARGET(
do_tags ALL
DEPENDS tags
)
ENDIF ()
IF (BUILD_EXAMPLES) IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples) ADD_SUBDIRECTORY(examples)
ENDIF () ENDIF ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment