Skip to content

Commit 629515a

Browse files
authored
Merge pull request libgit2#5481 from pks-t/pks/cmake-cleanups
CMake cleanups
2 parents 17641f1 + 511fb9e commit 629515a

22 files changed

+20
-58
lines changed

CMakeLists.txt

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,12 @@
1111
# Install:
1212
# > cmake --build . --target install
1313

14-
PROJECT(libgit2 C)
1514
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
16-
CMAKE_POLICY(SET CMP0015 NEW)
17-
IF(POLICY CMP0051)
18-
CMAKE_POLICY(SET CMP0051 NEW)
19-
ENDIF()
20-
IF(POLICY CMP0042)
21-
CMAKE_POLICY(SET CMP0042 NEW)
22-
ENDIF()
23-
IF(POLICY CMP0054)
24-
CMAKE_POLICY(SET CMP0054 NEW)
25-
ENDIF()
15+
16+
project(libgit2 C)
2617

2718
# Add find modules to the path
28-
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
19+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
2920

3021
INCLUDE(CheckLibraryExists)
3122
INCLUDE(CheckFunctionExists)
@@ -49,8 +40,6 @@ OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
4940
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
5041
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
5142
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
52-
OPTION(TAGS "Generate tags" OFF)
53-
OPTION(PROFILE "Generate profiling information" OFF)
5443
OPTION(ENABLE_TRACE "Enables tracing support" ON)
5544
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
5645
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
@@ -242,35 +231,27 @@ ELSE ()
242231
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
243232
ENDIF ()
244233

245-
ENABLE_WARNINGS(documentation)
246-
DISABLE_WARNINGS(missing-field-initializers)
247-
ENABLE_WARNINGS(strict-aliasing)
248-
ENABLE_WARNINGS(strict-prototypes)
249-
ENABLE_WARNINGS(declaration-after-statement)
250-
ENABLE_WARNINGS(shift-count-overflow)
251-
ENABLE_WARNINGS(unused-const-variable)
252-
ENABLE_WARNINGS(unused-function)
253-
ENABLE_WARNINGS(int-conversion)
234+
enable_warnings(documentation)
235+
disable_warnings(documentation-deprecated-sync)
236+
disable_warnings(missing-field-initializers)
237+
enable_warnings(strict-aliasing)
238+
enable_warnings(strict-prototypes)
239+
enable_warnings(declaration-after-statement)
240+
enable_warnings(shift-count-overflow)
241+
enable_warnings(unused-const-variable)
242+
enable_warnings(unused-function)
243+
enable_warnings(int-conversion)
254244

255245
# MinGW uses gcc, which expects POSIX formatting for printf, but
256246
# uses the Windows C library, which uses its own format specifiers.
257247
# Disable format specifier warnings.
258-
IF(MINGW)
259-
DISABLE_WARNINGS(format)
260-
DISABLE_WARNINGS(format-security)
261-
ELSE()
262-
ENABLE_WARNINGS(format)
263-
ENABLE_WARNINGS(format-security)
264-
ENDIF()
265-
266-
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
267-
DISABLE_WARNINGS(documentation-deprecated-sync)
268-
ENDIF()
269-
270-
IF (PROFILE)
271-
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
272-
SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
273-
ENDIF ()
248+
if(MINGW)
249+
disable_warnings(format)
250+
disable_warnings(format-security)
251+
else()
252+
enable_warnings(format)
253+
enable_warnings(format-security)
254+
endif()
274255
ENDIF()
275256

276257
# Ensure that MinGW provides the correct header files.
@@ -310,25 +291,6 @@ IF (BUILD_CLAR)
310291
ADD_SUBDIRECTORY(tests)
311292
ENDIF ()
312293

313-
IF (TAGS)
314-
FIND_PROGRAM(CTAGS ctags)
315-
IF (NOT CTAGS)
316-
MESSAGE(FATAL_ERROR "Could not find ctags command")
317-
ENDIF ()
318-
319-
FILE(GLOB_RECURSE SRC_ALL *.[ch])
320-
321-
ADD_CUSTOM_COMMAND(
322-
OUTPUT tags
323-
COMMAND ${CTAGS} -a ${SRC_ALL}
324-
DEPENDS ${SRC_ALL}
325-
)
326-
ADD_CUSTOM_TARGET(
327-
do_tags ALL
328-
DEPENDS tags
329-
)
330-
ENDIF ()
331-
332294
IF (BUILD_EXAMPLES)
333295
ADD_SUBDIRECTORY(examples)
334296
ENDIF ()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)