Skip to content

build: sink BlocksRuntime into its own directory #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,53 +116,6 @@ endif()

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

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(BlocksRuntime_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/BlocksRuntime)

# NOTE(compnerd) use the `BUILD_SHARED_LIBS` variable to determine what type
# of library to build. If it is true, we will generate shared libraries,
# otherwise we will generate static libraries.
add_library(BlocksRuntime
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/data.c
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/runtime.c)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_sources(BlocksRuntime
PRIVATE
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/BlocksRuntime.def)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(BlocksRuntime
PRIVATE
BlocksRuntime_STATIC)
endif()
endif()
set_target_properties(BlocksRuntime
PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
if(HAVE_OBJC AND CMAKE_DL_LIBS)
target_link_libraries(BlocksRuntime
PUBLIC
${CMAKE_DL_LIBS})
endif()

add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)

install(FILES
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/Block.h
DESTINATION
"${INSTALL_BLOCK_HEADERS_DIR}")
if(INSTALL_PRIVATE_HEADERS)
install(FILES
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/Block_private.h
DESTINATION
"${INSTALL_BLOCK_HEADERS_DIR}")
endif()
install(TARGETS
BlocksRuntime
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
RUNTIME DESTINATION bin)
endif()

check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
if(_GNU_SOURCE)
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE)
Expand Down
34 changes: 34 additions & 0 deletions src/BlocksRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

add_library(BlocksRuntime
data.c
runtime.c)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_sources(BlocksRuntime PRIVATE
BlocksRuntime.def)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(BlocksRuntime PRIVATE
BlocksRuntime_STATIC)
endif()
endif()

set_target_properties(BlocksRuntime PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
if(HAVE_OBJC AND CMAKE_DL_LIBS)
target_link_libraries(BlocksRuntime PUBLIC
${CMAKE_DL_LIBS})
endif()

add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)

install(FILES Block.h
DESTINATION ${INSTALL_BLOCK_HEADERS_DIR})
if(INSTALL_PRIVATE_HEADERS)
install(FILES Block_private.h
DESTINATION ${INSTALL_BLOCK_HEADERS_DIR})
endif()
install(TARGETS BlocksRuntime
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
RUNTIME DESTINATION bin)
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include(CheckCCompilerFlag)
include(SwiftSupport)
include(DTrace)

add_subdirectory(BlocksRuntime)

add_library(dispatch
allocator.c
apply.c
Expand Down