Skip to content

Commit

Permalink
Updates for CMake 3, CMAKE_MODULE_PATH as subproject
Browse files Browse the repository at this point in the history
Update minimum required version to 3.16 (supported by most current Linux
distributions). CMake 2 is no longer supported.

CMAKE_MODULE_PATH set with CMAKE_CURRENT_SOURCE_DIR instead of
CMAKE_SOURCE_DIR -- this enables libcbor use in an add_subdirectory
context, e.g. with CMake FetchContent.

subdirs is deprecated in favor of add_subdirectory.
  • Loading branch information
thewtex committed Feb 22, 2022
1 parent 3263254 commit de97626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Next
---------------------

- Minimum CMake version is 3.16 [[#201]](https://github.com/PJK/libcbor/pull/201) (by [thewtex@](https://github.com/thewtex))

0.9.0 (2021-11-14)
---------------------
- Improved pkg-config paths handling [[#164]](https://github.com/PJK/libcbor/pull/164) (by [jtojnar@](https://github.com/jtojnar))
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.16)
project(libcbor)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
include(CTest)

SET(CBOR_VERSION_MAJOR "0")
Expand Down Expand Up @@ -139,20 +139,20 @@ else()
message(STATUS "LTO is not enabled")
endif(use_lto)

subdirs(src)
add_subdirectory(src)
if(use_lto)
set_property(DIRECTORY src PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif(use_lto)

if (WITH_TESTS)
subdirs(test)
add_subdirectory(test)
if(use_lto)
set_property(DIRECTORY test PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif(use_lto)
endif (WITH_TESTS)

if (WITH_EXAMPLES)
subdirs(examples)
add_subdirectory(examples)
if(use_lto)
set_property(DIRECTORY examples PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif(use_lto)
Expand Down

0 comments on commit de97626

Please sign in to comment.