Skip to content

Commit

Permalink
versions CMakePPLang too
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmrichard committed Dec 6, 2023
1 parent dcc8b99 commit 15199e3
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ docs/source/make_tutorials.py
!docs/source/tutorials/index.rst
__pycache__/

#CLion project settings
#IDE project settings
.idea/
settings.json
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
#3.14 needed for FetchContent_MakeAvailable()
set(_ct_min_cmake_version "3.14" CACHE INTERNAL "")
cmake_minimum_required(VERSION "${_ct_min_cmake_version}") #Required for FetchContent_MakeAvailable()
cmake_minimum_required(VERSION "${_ct_min_cmake_version}")
project(CMakeTest VERSION 1.0.0 LANGUAGES NONE)

if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(_ct_min_cmake_version "${_ct_min_cmake_version}" PARENT_SCOPE) #Make sure projects using CMakeTest have this variable
#Make sure projects using CMakeTest have this variable
set(_ct_min_cmake_version "${_ct_min_cmake_version}" PARENT_SCOPE)
endif()

# Add cmake directory to CMake's module path, iff it's not already there
list(FIND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" path_has_cmake)
if(${path_has_cmake} STREQUAL "-1")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif()

# TODO: Should this be in the above if block?
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" CACHE STRING "" FORCE)

# Make sure projects including CMakeTest can find it too
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) #For projects including CMakeTest
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
endif()

include("${PROJECT_SOURCE_DIR}/cmake/get_cmaize.cmake")

include(get_cmakepp_lang)
include(get_cmaize)
include(cmake_test/cmake_test)

if("${BUILD_TESTING}")
Expand Down
3 changes: 2 additions & 1 deletion cmake/get_cmaize.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#]]

include_guard()
include(versions)

#[[
# This function encapsulates the process of getting CMakePP using CMake's
Expand All @@ -39,7 +40,7 @@ function(get_cmaize)
FetchContent_Declare(
cmaize
GIT_REPOSITORY https://github.com/CMakePP/CMaize
GIT_TAG 3cef972afa573c8d0c56a832341b8b20646f3d16
GIT_TAG ${CMAIZE_VERSION}
)
FetchContent_MakeAvailable(cmaize)

Expand Down
61 changes: 61 additions & 0 deletions cmake/get_cmakepp_lang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2023 CMakePP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#[[[ @module
# .. warning::
# This module is only used when building CMakeTest,
# and including it automatically pulls in CMakePPLang through
# FetchContent.
#]]

include_guard()
include(versions)

#[[
# This function encapsulates the process of getting CMakePPLang using CMake's
# FetchContent module. When CMaize supports find_or_build for CMake modules this
# file will be deprecated.
#]]
function(get_cmakepp_lang)
include(
cmakepp_lang/cmakepp_lang
OPTIONAL
RESULT_VARIABLE cmakepp_lang_found
)
if(NOT cmakepp_lang_found)
# Store whether we are building tests or not, then turn off the tests
set(build_testing_old "${BUILD_TESTING}")
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# Download CMakePP and bring it into scope
include(FetchContent)
FetchContent_Declare(
cmakepp_lang
GIT_REPOSITORY https://github.com/CMakePP/CMakePPLang
GIT_TAG ${CMAKEPP_LANG_VERSION}
)
FetchContent_MakeAvailable(cmakepp_lang)

set(
CMAKE_MODULE_PATH
"${CMAKE_MODULE_PATH}" "${cmakepp_lang_SOURCE_DIR}/cmake"
PARENT_SCOPE
)

# Restore the previous value
set(BUILD_TESTING "${build_testing_old}" CACHE BOOL "" FORCE)
endif()
endfunction()

# Call the function we just wrote to get CMaize
get_cmakepp_lang()
18 changes: 18 additions & 0 deletions cmake/versions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 CMakePP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include_guard()

set(CMAKEPP_LANG_VERSION v1.0.0)
set(CMAIZE_VERSION 9acce67d19097e50fc744d76d0c49897bc69b9da)

0 comments on commit 15199e3

Please sign in to comment.