brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 9fef16e Raw
97 lines · plain
1cmake_minimum_required(VERSION 3.26)2 3project(libc++-modules LANGUAGES CXX)4 5# Enable CMake's module support6if(CMAKE_VERSION VERSION_LESS "3.28.0")7  if(CMAKE_VERSION VERSION_LESS "3.27.0")8    set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")9  else()10    set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7")11  endif()12  set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)13else()14  cmake_policy(VERSION 3.28)15endif()16 17# Default to C++ extensions being off. Libc++'s modules support have trouble18# with extensions right now.19set(CMAKE_CXX_EXTENSIONS OFF)20 21# Propagates the CMake options to the modules.22#23# This uses the std module hard-coded since the std.compat module does not24# depend on these flags.25macro(compile_define_if_not condition def)26  if (NOT ${condition})27    target_compile_definitions(std PRIVATE ${def})28  endif()29endmacro()30macro(compile_define_if condition def)31  if (${condition})32    target_compile_definitions(std PRIVATE ${def})33  endif()34endmacro()35 36### STD37 38add_library(std)39target_sources(std40  PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES41    std.cppm42)43 44target_include_directories(std SYSTEM PUBLIC @LIBCXX_CONFIGURED_INCLUDE_DIRS@)45 46if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)47  target_compile_options(std PUBLIC -fno-exceptions)48endif()49 50target_compile_options(std51  PUBLIC52    -nostdinc++53    @LIBCXX_COMPILE_FLAGS@54)55target_compile_options(std56  PRIVATE57    -Wno-reserved-module-identifier58    -Wno-reserved-user-defined-literal59)60target_link_options(std PUBLIC -nostdlib++ -Wl,-rpath,@LIBCXX_LIBRARY_DIR@ -L@LIBCXX_LIBRARY_DIR@)61target_link_libraries(std c++)62set_target_properties(std63  PROPERTIES64    OUTPUT_NAME   "c++std"65)66 67### STD.COMPAT68 69add_library(std.compat)70target_sources(std.compat71  PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES72    std.compat.cppm73)74 75target_include_directories(std.compat SYSTEM PUBLIC @LIBCXX_CONFIGURED_INCLUDE_DIRS@)76 77if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)78  target_compile_options(std.compat PUBLIC -fno-exceptions)79endif()80 81target_compile_options(std.compat82  PUBLIC83    -nostdinc++84    @LIBCXX_COMPILE_FLAGS@85)86target_compile_options(std.compat87 PRIVATE88    -Wno-reserved-module-identifier89    -Wno-reserved-user-defined-literal90)91set_target_properties(std.compat92  PROPERTIES93    OUTPUT_NAME   "c++std.compat"94)95add_dependencies(std.compat std)96target_link_libraries(std.compat PUBLIC std c++)97