Skip to content

Commit 21bd317

Browse files
committed
Initial commit
0 parents  commit 21bd317

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake-build-*/
2+
*build*/
3+
.idea/
4+
squashfs-root/
5+
*.AppImage
6+
*.*swp

LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright 2021 TheAssassin
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CMake Scripts
2+
3+
Intended to be used as a submodule from linuxdeploy projects. Implements logic common to many projects.

include-or-build-gtest.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
include(${CMAKE_CURRENT_LIST_DIR}/log.cmake)
2+
3+
# 3.14 is required for FetchContent
4+
cmake_minimum_required(VERSION 3.14)
5+
6+
find_package(PkgConfig)
7+
8+
set(prefix __ld_gtest)
9+
# 1.11.0 introduced various matchers that can be used with EXPECT_THAT (e.g., ThrowsMessage)
10+
set(required_version 1.11.0)
11+
12+
pkg_check_modules(${prefix} gtest>=${required_version} IMPORTED_TARGET)
13+
14+
if(TARGET gtest)
15+
__cmake_scripts_log("target gtest found, not setting up again")
16+
else()
17+
if(${prefix}_FOUND)
18+
__cmake_scripts_log("Using system gtest")
19+
add_library(gtest ALIAS PkgConfig::${prefix})
20+
else()
21+
__cmake_scripts_log("googletest not found or too old on system, fetching from GitHub")
22+
23+
include(FetchContent)
24+
25+
FetchContent_Declare(
26+
${prefix}
27+
GIT_REPOSITORY https://github.com/google/googletest.git
28+
GIT_TAG release-${required_version}
29+
)
30+
31+
FetchContent_MakeAvailable(${prefix})
32+
endif()
33+
endif()

log.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function(__cmake_scripts_log MESSAGE)
2+
set(log_prefix "[cmake-scripts in ${PROJECT_NAME}]")
3+
message(STATUS "${log_prefix} ${MESSAGE}")
4+
endfunction()

0 commit comments

Comments
 (0)