Skip to content

Commit

Permalink
build: remove custom variables for cmark handling
Browse files Browse the repository at this point in the history
Use the imported target to handle the include path and link libraries.
This allows CMake to properly handle dependencies and removes the
custom handling logic that we have relied on now that CMark properly
supports export targets.
  • Loading branch information
compnerd committed Jan 28, 2020
1 parent 1fff12f commit f53ae41
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 67 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,6 @@ execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")
message(STATUS "C Compiler (${CMAKE_C_COMPILER}) Version: ${CMAKE_C_COMPILER_VERSION}")
message(STATUS "C++ Compiler (${CMAKE_CXX_COMPILER}) Version: ${CMAKE_CXX_COMPILER_VERSION}")
if(SWIFT_PATH_TO_CMARK_BUILD)
execute_process(COMMAND ${SWIFT_PATH_TO_CMARK_BUILD}/src/cmark --version
OUTPUT_VARIABLE _CMARK_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "CMark Version: ${_CMARK_VERSION}")
endif()
message(STATUS "")

include(SwiftSharedCMakeConfig)
Expand Down
5 changes: 0 additions & 5 deletions cmake/modules/SwiftConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ set(SWIFT_LIBRARY_DIR "@SWIFT_LIBRARY_DIRS@")
set(SWIFT_CMAKE_DIR "@SWIFT_CMAKE_DIR@")
set(SWIFT_BINARY_DIR "@SWIFT_BINARY_DIR@")

set(CMARK_TARGETS_FILE @SWIFT_PATH_TO_CMARK_BUILD@/src/cmarkTargets.cmake)
if(NOT TARGET libcmark_static AND EXISTS ${CMARK_TARGETS_FILE})
include(${CMARK_TARGETS_FILE})
endif()

if(NOT TARGET swift)
set(SWIFT_EXPORTED_TARGETS "@SWIFT_CONFIG_EXPORTS@")
include("@SWIFT_EXPORTS_FILE@")
Expand Down
53 changes: 6 additions & 47 deletions cmake/modules/SwiftSharedCMakeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,30 +171,10 @@ macro(swift_common_standalone_build_config_clang product)
endmacro()

macro(swift_common_standalone_build_config_cmark product)
set(${product}_PATH_TO_CMARK_SOURCE "${${product}_PATH_TO_CMARK_SOURCE}"
CACHE PATH "Path to CMark source code.")
set(${product}_PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
CACHE PATH "Path to the directory where CMark was built.")
set(${product}_CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}" CACHE PATH
"Path to the directory where CMark was installed.")
get_filename_component(PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
ABSOLUTE)
get_filename_component(CMARK_MAIN_SRC_DIR "${${product}_PATH_TO_CMARK_SOURCE}"
ABSOLUTE)
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
ABSOLUTE)

set(CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR}/src")
set(CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD}/src")

file(TO_CMAKE_PATH "${CMARK_MAIN_INCLUDE_DIR}" CMARK_MAIN_INCLUDE_DIR)
file(TO_CMAKE_PATH "${CMARK_BUILD_INCLUDE_DIR}" CMARK_BUILD_INCLUDE_DIR)

include_directories("${CMARK_MAIN_INCLUDE_DIR}"
"${CMARK_BUILD_INCLUDE_DIR}")

include(${PATH_TO_CMARK_BUILD}/src/cmarkTargets.cmake)
add_definitions(-DCMARK_STATIC_DEFINE)
find_package(cmark CONFIG)
if(NOT cmark_FOUND)
find_package(cmark REQUIRED)
endif()
endmacro()

# Common cmake project config for standalone builds.
Expand Down Expand Up @@ -229,29 +209,8 @@ macro(swift_common_unified_build_config product)
set(LLVM_PACKAGE_VERSION ${PACKAGE_VERSION})
set(LLVM_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")

# If cmark was checked out into tools/cmark, expect to build it as
# part of the unified build.
if(EXISTS "${LLVM_EXTERNAL_CMARK_SOURCE_DIR}")
set(${product}_PATH_TO_CMARK_SOURCE "${LLVM_EXTERNAL_CMARK_SOURCE_DIR}")
set(${product}_PATH_TO_CMARK_BUILD "${CMAKE_BINARY_DIR}/tools/cmark")
set(${product}_CMARK_LIBRARY_DIR "${CMAKE_BINARY_DIR}/lib")

get_filename_component(CMARK_MAIN_SRC_DIR "${${product}_PATH_TO_CMARK_SOURCE}"
ABSOLUTE)
get_filename_component(PATH_TO_CMARK_BUILD "${${product}_PATH_TO_CMARK_BUILD}"
ABSOLUTE)
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
ABSOLUTE)

set(CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD}/src")
set(CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR}/src")
endif()

include_directories(
"${CLANG_BUILD_INCLUDE_DIR}"
"${CLANG_MAIN_INCLUDE_DIR}"
"${CMARK_MAIN_INCLUDE_DIR}"
"${CMARK_BUILD_INCLUDE_DIR}")
include_directories(${CLANG_BUILD_INCLUDE_DIR}
${CLANG_MAIN_INCLUDE_DIR})

include(AddSwiftTableGen) # This imports TableGen from LLVM.

Expand Down
8 changes: 3 additions & 5 deletions lib/Markup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ add_swift_host_library(swiftMarkup STATIC
AST.cpp
LineList.cpp
Markup.cpp)
target_link_libraries(swiftMarkup PRIVATE
target_link_libraries(swiftMarkup INTERFACE
libcmark_static)
target_compile_definitions(swiftMarkup
PRIVATE
CMARK_STATIC_DEFINE)

target_compile_definitions(swiftMarkup PRIVATE
CMARK_STATIC_DEFINE)
2 changes: 2 additions & 0 deletions tools/SourceKit/lib/SwiftLang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ add_sourcekit_library(SourceKitSwiftLang
objcarcopts
profiledata
)
target_compile_definitions(SourceKitSwiftLang PRIVATE
CMARK_STATIC_DEFINE)
target_link_libraries(SourceKitSwiftLang PRIVATE
SourceKitCore
swiftDriver
Expand Down
3 changes: 1 addition & 2 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1682,8 +1682,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DClang_DIR:PATH=${llvm_build_dir}/lib/cmake/clang
-DLLVM_DIR:PATH=${llvm_build_dir}/lib/cmake/llvm
-DSWIFT_PATH_TO_CMARK_SOURCE:PATH="${CMARK_SOURCE_DIR}"
-DSWIFT_PATH_TO_CMARK_BUILD:PATH="$(build_directory ${host} cmark)"
-Dcmark_DIR:PATH=$(build_directory ${host} cmark)/src
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH="${LIBDISPATCH_SOURCE_DIR}"
-DSWIFT_PATH_TO_LIBDISPATCH_BUILD:PATH="$(build_directory ${host} libdispatch)"
)
Expand Down
3 changes: 1 addition & 2 deletions utils/build-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ cmake "%source_root%\swift"^
-DCMAKE_CXX_COMPILER=cl^
-DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
-DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
-DSWIFT_PATH_TO_CMARK_BUILD:PATH=%build_root%\cmark^
-DSWIFT_PATH_TO_CMARK_SOURCE:PATH=%source_root%\cmark^
-Dcmark_DIR:PATH=%build_root%\cmark\src^
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH=%source_root%\swift-corelibs-libdispatch^
-DLLVM_DIR:PATH=%build_root%\llvm\lib\cmake\llvm^
-DSWIFT_INCLUDE_DOCS:BOOL=NO^
Expand Down

0 comments on commit f53ae41

Please sign in to comment.