Skip to content

Commit

Permalink
CMake: update minimum cmake version to avoid warnings
Browse files Browse the repository at this point in the history
CMake 3.27 issued a deprecation warning saying cmake <3.5 would no longer
be supported.

closes adishavit#86
  • Loading branch information
theodoregoetz committed Feb 26, 2024
1 parent 431bf32 commit f3ee72f
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)

project(argh)

Expand All @@ -16,39 +16,39 @@ option(BUILD_EXAMPLES "Build examples. Uncheck for install only runs"
${ARGH_MASTER_PROJECT})

if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|GNU)")
list(APPEND flags "-Wall" "-Wextra" "-Wshadow" "-Wnon-virtual-dtor" "-pedantic")
list(APPEND flags "-Wall" "-Wextra" "-Wshadow" "-Wnon-virtual-dtor" "-pedantic")
elseif(MSVC)
list(APPEND flags "/W4" "/WX")
list(APPEND flags "/W4" "/WX")
endif()

if(BUILD_EXAMPLES)
add_executable(argh_example example.cpp)
target_compile_options(argh_example PRIVATE ${flags})
add_executable(argh_example example.cpp)
target_compile_options(argh_example PRIVATE ${flags})
endif()
if(BUILD_TESTS)
add_executable(argh_tests argh_tests.cpp)
target_compile_options(argh_tests PRIVATE ${flags})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT argh_tests)
add_executable(argh_tests argh_tests.cpp)
target_compile_options(argh_tests PRIVATE ${flags})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT argh_tests)
endif()

add_library(argh INTERFACE)
target_include_directories(argh INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)

if(ARGH_MASTER_PROJECT)
install(TARGETS argh EXPORT arghTargets)

include(GNUInstallDirs)
install(FILES "${CMAKE_CURRENT_LIST_DIR}/argh.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES "${CMAKE_CURRENT_LIST_DIR}/LICENSE" DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES "${CMAKE_CURRENT_LIST_DIR}/README.md" DESTINATION ${CMAKE_INSTALL_DOCDIR})

if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL Linux)
# this might be a bit too restrictive, since for other (BSD, ...) this might apply also
# but this can be fixed later in extra pull requests from people on the platform
install(FILES argh-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/argh)
install(EXPORT arghTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/argh)
else()
install(FILES argh-config.cmake DESTINATION CMake)
install(EXPORT arghTargets DESTINATION CMake)
endif()
install(TARGETS argh EXPORT arghTargets)

include(GNUInstallDirs)
install(FILES "${CMAKE_CURRENT_LIST_DIR}/argh.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES "${CMAKE_CURRENT_LIST_DIR}/LICENSE" DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES "${CMAKE_CURRENT_LIST_DIR}/README.md" DESTINATION ${CMAKE_INSTALL_DOCDIR})

if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL Linux)
# this might be a bit too restrictive, since for other (BSD, ...) this might apply also
# but this can be fixed later in extra pull requests from people on the platform
install(FILES argh-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/argh)
install(EXPORT arghTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/argh)
else()
install(FILES argh-config.cmake DESTINATION CMake)
install(EXPORT arghTargets DESTINATION CMake)
endif()
endif()

0 comments on commit f3ee72f

Please sign in to comment.