Skip to content

Commit 17f97af

Browse files
committed
Make docs-ci.cmake a little less intrusive
1 parent 9d4cea6 commit 17f97af

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

cmake-init/templates/c/executable/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES C
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

cmake-init/templates/c/header/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES NONE
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

cmake-init/templates/c/shared/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES C
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

cmake-init/templates/common/cmake/docs-ci.cmake

+14-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ endif()
4242
# ---- Process project() call in CMakeLists.txt ----
4343

4444
file(READ "${src}/CMakeLists.txt" content)
45-
string(FIND "${content}" "project(" start_index)
46-
string(FIND "${content}" "\n) #" end_index)
47-
math(EXPR length "${end_index} + 2 - ${start_index}")
48-
string(SUBSTRING "${content}" "${start_index}" "${length}" content)
49-
file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n")
45+
46+
string(FIND "${content}" "project(" index)
47+
if(index EQUAL "-1")
48+
message(FATAL_ERROR "Could not find \"project(\"")
49+
endif()
50+
string(SUBSTRING "${content}" "${index}" -1 content)
51+
52+
string(FIND "${content}" "\n)\n" index)
53+
if(index EQUAL "-1")
54+
message(FATAL_ERROR "Could not find \"\\n)\\n\"")
55+
endif()
56+
string(SUBSTRING "${content}" 0 "${index}" content)
57+
58+
file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n)\n")
5059

5160
macro(list_pop_front list out)
5261
list(GET "${list}" 0 "${out}")

cmake-init/templates/executable/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES CXX
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

cmake-init/templates/header/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES NONE
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

cmake-init/templates/shared/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
DESCRIPTION "%(description)s"
99
HOMEPAGE_URL "%(homepage)s"
1010
LANGUAGES CXX
11-
) #
11+
)
1212

1313
include(cmake/project-is-top-level.cmake)
1414
include(cmake/variables.cmake)

0 commit comments

Comments
 (0)