Skip to content

Commit 7910811

Browse files
compnerdrokhinip
authored andcommitted
build: sink BlocksRuntime into its own directory
This follows the CMake recommendations for the tree layout. It makes it easier to follow the build infrastructure, and prepares the tree for migration to CMake 3.15 to enable Swift support. Signed-off-by: Rokhini Prabhu <[email protected]>
1 parent d8986aa commit 7910811

File tree

3 files changed

+36
-47
lines changed

3 files changed

+36
-47
lines changed

CMakeLists.txt

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -116,53 +116,6 @@ endif()
116116

117117
option(INSTALL_PRIVATE_HEADERS "installs private headers in the same location as the public ones" OFF)
118118

119-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
120-
set(BlocksRuntime_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/BlocksRuntime)
121-
122-
# NOTE(compnerd) use the `BUILD_SHARED_LIBS` variable to determine what type
123-
# of library to build. If it is true, we will generate shared libraries,
124-
# otherwise we will generate static libraries.
125-
add_library(BlocksRuntime
126-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/data.c
127-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/runtime.c)
128-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
129-
target_sources(BlocksRuntime
130-
PRIVATE
131-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/BlocksRuntime.def)
132-
if(NOT BUILD_SHARED_LIBS)
133-
target_compile_definitions(BlocksRuntime
134-
PRIVATE
135-
BlocksRuntime_STATIC)
136-
endif()
137-
endif()
138-
set_target_properties(BlocksRuntime
139-
PROPERTIES
140-
POSITION_INDEPENDENT_CODE TRUE)
141-
if(HAVE_OBJC AND CMAKE_DL_LIBS)
142-
target_link_libraries(BlocksRuntime
143-
PUBLIC
144-
${CMAKE_DL_LIBS})
145-
endif()
146-
147-
add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
148-
149-
install(FILES
150-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/Block.h
151-
DESTINATION
152-
"${INSTALL_BLOCK_HEADERS_DIR}")
153-
if(INSTALL_PRIVATE_HEADERS)
154-
install(FILES
155-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/Block_private.h
156-
DESTINATION
157-
"${INSTALL_BLOCK_HEADERS_DIR}")
158-
endif()
159-
install(TARGETS
160-
BlocksRuntime
161-
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
162-
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
163-
RUNTIME DESTINATION bin)
164-
endif()
165-
166119
check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
167120
if(_GNU_SOURCE)
168121
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE)

src/BlocksRuntime/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
add_library(BlocksRuntime
3+
data.c
4+
runtime.c)
5+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
6+
target_sources(BlocksRuntime PRIVATE
7+
BlocksRuntime.def)
8+
9+
if(NOT BUILD_SHARED_LIBS)
10+
target_compile_definitions(BlocksRuntime PRIVATE
11+
BlocksRuntime_STATIC)
12+
endif()
13+
endif()
14+
15+
set_target_properties(BlocksRuntime PROPERTIES
16+
POSITION_INDEPENDENT_CODE TRUE
17+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
18+
if(HAVE_OBJC AND CMAKE_DL_LIBS)
19+
target_link_libraries(BlocksRuntime PUBLIC
20+
${CMAKE_DL_LIBS})
21+
endif()
22+
23+
add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
24+
25+
install(FILES Block.h
26+
DESTINATION ${INSTALL_BLOCK_HEADERS_DIR})
27+
if(INSTALL_PRIVATE_HEADERS)
28+
install(FILES Block_private.h
29+
DESTINATION ${INSTALL_BLOCK_HEADERS_DIR})
30+
endif()
31+
install(TARGETS BlocksRuntime
32+
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
33+
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
34+
RUNTIME DESTINATION bin)

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ include(CheckCCompilerFlag)
33
include(SwiftSupport)
44
include(DTrace)
55

6+
add_subdirectory(BlocksRuntime)
7+
68
add_library(dispatch
79
allocator.c
810
apply.c

0 commit comments

Comments
 (0)