Verified Commit 2011bf4d authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

CMake: refactor targets and source files

All library headers now live under lib/scord/
parent df4cd173
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ list(APPEND examples_c

add_library(c_examples_common STATIC)
target_sources(c_examples_common PUBLIC common.h PRIVATE common.c)
target_link_libraries(c_examples_common common::api::types)
target_link_libraries(c_examples_common libscord_c_types)

foreach(example IN LISTS examples_c)
  add_executable(${example}_c)
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ list(APPEND examples_cxx

add_library(cxx_examples_common STATIC)
target_sources(cxx_examples_common PUBLIC common.hpp PRIVATE common.cpp)
target_link_libraries(cxx_examples_common common::api::types)
target_link_libraries(cxx_examples_common libscord_cxx_types)

foreach(example IN LISTS examples_cxx)
  add_executable(${example}_cxx)
+0 −5
Original line number Diff line number Diff line
@@ -45,11 +45,6 @@ target_include_directories(_rpc_client INTERFACE
  ${CMAKE_CURRENT_SOURCE_DIR})
add_library(common::network::rpc_client ALIAS _rpc_client)

add_subdirectory(api)
target_include_directories(_api_types INTERFACE
  ${CMAKE_CURRENT_SOURCE_DIR})
add_library(common::api::types ALIAS _api_types)

add_subdirectory(abt_cxx)
target_include_directories(_abt_cxx INTERFACE
  ${CMAKE_CURRENT_SOURCE_DIR})

src/common/api/CMakeLists.txt

deleted100644 → 0
+0 −35
Original line number Diff line number Diff line
################################################################################
# Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain            #
#                                                                              #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
#                                                                              #
# This file is part of scord.                                                  #
#                                                                              #
# scord is free software: you can redistribute it and/or modify                #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# scord is distributed in the hope that it will be useful,                     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with scord.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

add_library(_api_types STATIC)

target_sources(_api_types PUBLIC scord/types.h scord/types.hpp PRIVATE
  types.c types.cpp scord/internal_types.hpp errors.c)

target_include_directories(_api_types PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(_api_types PRIVATE
  Margo::Margo common::logger PUBLIC fmt::fmt common::abt_cxx)

set_property(TARGET _api_types PROPERTY POSITION_INDEPENDENT_CODE ON)
+63 −6
Original line number Diff line number Diff line
@@ -22,6 +22,65 @@
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

################################################################################
# Create a target for the C type definitions so that we can
# include them where needed
################################################################################
add_library(libscord_c_types STATIC)

target_sources(libscord_c_types PRIVATE scord/types.h types.c errors.c)

set(public_headers, "")
list(APPEND public_headers "scord/types.h")

set_target_properties(
  libscord_c_types PROPERTIES PUBLIC_HEADER "${public_headers}"
)

target_include_directories(
  libscord_c_types PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
                          $<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)

target_link_libraries(
  libscord_c_types
  PRIVATE Margo::Margo common::logger
  PUBLIC fmt::fmt common::abt_cxx
)

set_property(TARGET libscord_c_types PROPERTY POSITION_INDEPENDENT_CODE ON)

################################################################################
# Create a target for the C++ type definitions so that we can
# include them where needed
################################################################################
add_library(libscord_cxx_types STATIC)

target_sources(libscord_cxx_types PRIVATE scord/types.hpp types.cpp)

set(public_headers, "")
list(APPEND public_headers "scord/types.hpp")

set_target_properties(
  libscord_cxx_types PROPERTIES PUBLIC_HEADER "${public_headers}"
)

target_include_directories(
  libscord_cxx_types PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
                            $<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)

target_link_libraries(
  libscord_cxx_types
  PRIVATE libscord_c_types Margo::Margo common::logger
  PUBLIC fmt::fmt common::abt_cxx
)

set_property(TARGET libscord_cxx_types PROPERTY POSITION_INDEPENDENT_CODE ON)

################################################################################
# Create a target for the actual library that will be used by clients
################################################################################
add_library(libscord SHARED)

target_sources(
@@ -30,10 +89,8 @@ target_sources(
  PRIVATE libscord.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp env.hpp
)

list(APPEND public_headers "scord/scord.h"
     "${CMAKE_SOURCE_DIR}/src/common/api/scord/types.h" "scord/scord.hpp"
     "${CMAKE_SOURCE_DIR}/src/common/api/scord/types.hpp"
)
set(public_headers, "")
list(APPEND public_headers "scord/scord.h" "scord/scord.hpp")

set_target_properties(libscord PROPERTIES PUBLIC_HEADER "${public_headers}")

@@ -45,13 +102,13 @@ target_include_directories(
target_link_libraries(
  libscord
  PRIVATE common::network::rpc_client
  PUBLIC tl::expected common::api::types
  PUBLIC tl::expected libscord_c_types libscord_cxx_types
)

set_target_properties(libscord PROPERTIES OUTPUT_NAME "scord")

install(
  TARGETS libscord
  TARGETS libscord libscord_c_types libscord_cxx_types
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
Loading