Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1013 Split iceoryx_platform cmake code into own file
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Jan 13, 2022
1 parent 1820999 commit 2a3898c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 63 deletions.
76 changes: 13 additions & 63 deletions iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2019 - 2021 by Robert Bosch GmbH. All rights reserved.
# Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
# Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -104,14 +104,11 @@ if(GTest_FOUND) # only GTest_FOUND, just in case someone want's to use iceoryx_h
GTest::gtest
GTest::gmock
${CMAKE_DL_LIBS}
$<$<PLATFORM_ID:Linux>: rt>
)

target_compile_options(iceoryx_hoofs_testing PRIVATE ${ICEORYX_WARNINGS})

if(LINUX)
target_link_libraries(iceoryx_hoofs_testing PRIVATE rt)
endif()

setup_install_directories_and_export_package(
TARGETS iceoryx_hoofs_testing
INCLUDE_DIRECTORY testing/include/
Expand Down Expand Up @@ -183,68 +180,22 @@ set_target_properties(iceoryx_hoofs PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

if(LINUX)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/platform/linux/)
target_link_libraries(iceoryx_hoofs PRIVATE acl atomic ${CODE_COVERAGE_LIBS})
elseif(QNX)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/platform/qnx/)
elseif(APPLE)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/platform/mac/)
elseif(WIN32)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/platform/win/)
else()
message(WARNING "Could not detect supported platform, but I'm feeling lucky today." )
endif()

# this must be recurse since every platform has potentially different cpp files
file ( GLOB_RECURSE ICEORYX_PLATFORM_FILES
${ICEORYX_PLATFORM}/source/*.cpp
)
add_library(iceoryx_platform ${ICEORYX_PLATFORM_FILES})
target_include_directories(iceoryx_platform
PUBLIC
$<BUILD_INTERFACE:${ICEORYX_PLATFORM}/include/>
$<INSTALL_INTERFACE:include/${PREFIX}>
)
add_library(iceoryx_hoofs::iceoryx_platform ALIAS iceoryx_platform)
set_target_properties(iceoryx_platform PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
POSITION_INDEPENDENT_CODE ON
)

target_link_libraries(iceoryx_platform PRIVATE ${ICEORYX_SANITIZER_FLAGS})

target_compile_options(iceoryx_platform PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

if(LINUX)
target_link_libraries(iceoryx_platform
PUBLIC
rt
pthread
)
endif(LINUX)

if(PERFORM_CLANG_TIDY)
set_target_properties(
iceoryx_hoofs PROPERTIES CXX_CLANG_TIDY "${PERFORM_CLANG_TIDY}"
)
endif(PERFORM_CLANG_TIDY)

if(QNX)
target_link_libraries(iceoryx_hoofs
PUBLIC
iceoryx_hoofs::iceoryx_platform
PRIVATE
socket
${ICEORYX_SANITIZER_FLAGS})
else()
target_link_libraries(iceoryx_hoofs
PUBLIC
iceoryx_hoofs::iceoryx_platform
PRIVATE
${ICEORYX_SANITIZER_FLAGS})
endif(QNX)
add_subdirectory(platform)
add_library(iceoryx_hoofs::iceoryx_platform ALIAS iceoryx_platform)

target_link_libraries(iceoryx_hoofs
PUBLIC
iceoryx_hoofs::iceoryx_platform
PRIVATE
${ICEORYX_SANITIZER_FLAGS}
$<$<PLATFORM_ID:Linux>: acl atomic ${CODE_COVERAGE_LIBS}>
)

target_compile_options(iceoryx_hoofs PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

Expand All @@ -255,8 +206,6 @@ target_include_directories(iceoryx_hoofs
$<INSTALL_INTERFACE:include/${PREFIX}>
)



#
########## exporting library ##########
#
Expand All @@ -267,6 +216,7 @@ install(
DESTINATION include/${PREFIX}
COMPONENT dev
)

setup_install_directories_and_export_package(
TARGETS iceoryx_hoofs iceoryx_platform
INCLUDE_DIRECTORY include/
Expand Down
65 changes: 65 additions & 0 deletions iceoryx_hoofs/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2019 - 2021 by Robert Bosch GmbH. All rights reserved.
# Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.5)

if(LINUX)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/linux/)
elseif(QNX)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/qnx/)
elseif(APPLE)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/mac/)
elseif(WIN32)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/win/)
else()
message(WARNING "Could not detect supported platform, but I'm feeling lucky today." )
endif()

set(ICEORYX_PLATFORM ${ICEORYX_PLATFORM} CACHE PATH "" FORCE)

# this must be recurse since every platform has potentially different cpp files
file ( GLOB_RECURSE ICEORYX_PLATFORM_FILES
${ICEORYX_PLATFORM}/source/*.cpp
)
add_library(iceoryx_platform ${ICEORYX_PLATFORM_FILES})
target_include_directories(iceoryx_platform
PUBLIC
$<BUILD_INTERFACE:${ICEORYX_PLATFORM}/include/>
$<INSTALL_INTERFACE:include/${PREFIX}>
)
set_target_properties(iceoryx_platform PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD ${ICEORYX_CXX_STANDARD}
POSITION_INDEPENDENT_CODE ON
)

target_link_libraries(iceoryx_platform PRIVATE ${ICEORYX_SANITIZER_FLAGS})

target_compile_options(iceoryx_platform PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS})

if(LINUX)
target_link_libraries(iceoryx_platform
PUBLIC
rt
pthread
)
elseif(QNX)
target_link_libraries(iceoryx_platform
PRIVATE
socket
)
endif()

0 comments on commit 2a3898c

Please sign in to comment.