Skip to content

Commit db964d3

Browse files
committed
[cmake] Refactor out cmark related config from swift_common_standalone_build_config to swift_common_standalone_build_config_cmark.
This is apart of a series of patches that separates configuration of llvm/clang/cmark in swift_common_standalone_build_config. Right now each project has configuration occurring in a mixed up way. By refactoring it becomes much easier to read the code. rdar://26154980
1 parent bd43806 commit db964d3

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ else()
1212
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
1313
endif()
1414

15+
macro(swift_common_standalone_build_config_cmark product)
16+
set(${product}_PATH_TO_CMARK_SOURCE "${${product}_PATH_TO_CMARK_SOURCE}"
17+
CACHE PATH "Path to CMark source code.")
18+
set(${product}_PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
19+
CACHE PATH "Path to the directory where CMark was built.")
20+
set(${product}_CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}" CACHE PATH
21+
"Path to the directory where CMark was installed.")
22+
get_filename_component(PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
23+
ABSOLUTE)
24+
get_filename_component(CMARK_MAIN_SRC_DIR "${${product}_PATH_TO_CMARK_SOURCE}"
25+
ABSOLUTE)
26+
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
27+
ABSOLUTE)
28+
set(CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR}/src")
29+
set(CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD}/src")
30+
include_directories("${CMARK_MAIN_INCLUDE_DIR}"
31+
"${CMARK_BUILD_INCLUDE_DIR}")
32+
endmacro()
33+
1534
# Common cmake project config for standalone builds.
1635
#
1736
# Parameters:
@@ -74,19 +93,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
7493
set(${product}_PATH_TO_CLANG_BUILD "${PATH_TO_LLVM_BUILD}" CACHE PATH
7594
"Path to the directory where Clang was built or installed.")
7695

77-
set(${product}_PATH_TO_CMARK_SOURCE "${${product}_PATH_TO_CMARK_SOURCE}"
78-
CACHE PATH "Path to CMark source code.")
79-
set(${product}_PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
80-
CACHE PATH "Path to the directory where CMark was built.")
81-
set(${product}_CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}" CACHE PATH
82-
"Path to the directory where CMark was installed.")
83-
get_filename_component(PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
84-
ABSOLUTE)
85-
get_filename_component(CMARK_MAIN_SRC_DIR "${${product}_PATH_TO_CMARK_SOURCE}"
86-
ABSOLUTE)
87-
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
88-
ABSOLUTE)
89-
9096
if(NOT EXISTS "${${product}_PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h")
9197
message(FATAL_ERROR "Please set ${product}_PATH_TO_CLANG_SOURCE to the root directory of Clang's source code.")
9298
else()
@@ -133,16 +139,12 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
133139
"Version number that will be placed into the libclang library , in the form XX.YY")
134140

135141
set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
136-
set(CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR}/src")
137-
set(CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD}/src")
138142

139143
set(CMAKE_INCLUDE_CURRENT_DIR ON)
140144
include_directories("${PATH_TO_LLVM_BUILD}/include"
141145
"${LLVM_MAIN_INCLUDE_DIR}"
142146
"${CLANG_BUILD_INCLUDE_DIR}"
143-
"${CLANG_MAIN_INCLUDE_DIR}"
144-
"${CMARK_MAIN_INCLUDE_DIR}"
145-
"${CMARK_BUILD_INCLUDE_DIR}")
147+
"${CLANG_MAIN_INCLUDE_DIR}")
146148
foreach (INCLUDE_DIR ${LLVM_INCLUDE_DIRS})
147149
include_directories(${INCLUDE_DIR})
148150
endforeach ()
@@ -168,6 +170,8 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
168170
if (LLVM_ENABLE_DOXYGEN)
169171
find_package(Doxygen REQUIRED)
170172
endif()
173+
174+
swift_common_standalone_build_config_cmark(${product})
171175
endmacro()
172176

173177
# Common cmake project config for unified builds.

0 commit comments

Comments
 (0)