Visitar URL original
CMake build with find_package support and automatic translation. by alexreinking · Pull Request #15 · hsutter/cppfront · GitHub
Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Prefix all targets with cppfront_
  • Loading branch information
alexreinking committed Oct 2, 2022
commit 67f4e93c7cc20ab33a28773955ef1368cc52f25a
46 changes: 35 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,64 @@ project(
VERSION 0.1.0
)

##
# Project options

option(
CPPFRONT_INSTALL_RULES "Enable install rules for cppfront" "${PROJECT_IS_TOP_LEVEL}"
Comment thread
alexreinking marked this conversation as resolved.
Resolved
)

add_executable(cppfront source/cppfront.cpp)
add_executable(cppfront::cppfront ALIAS cppfront)
target_compile_features(cppfront PRIVATE cxx_std_20)
##
# Target definition for cppfront executable

add_executable(cppfront_cppfront source/cppfront.cpp)
add_executable(cppfront::cppfront ALIAS cppfront_cppfront)
set_target_properties(
cppfront_cppfront
PROPERTIES
OUTPUT_NAME cppfront
EXPORT_NAME cppfront
)

target_compile_features(cppfront_cppfront PRIVATE cxx_std_20)
target_sources(
cppfront
cppfront_cppfront
PRIVATE
FILE_SET HEADERS
Comment thread
alexreinking marked this conversation as resolved.
Resolved
BASE_DIRS source
FILES source/common.h source/lex.h source/load.h source/parse.h source/sema.h
)

add_library(cpp2util INTERFACE)
add_library(cppfront::cpp2util ALIAS cpp2util)
target_compile_features(cpp2util INTERFACE cxx_std_20)
##
# Target definition for cpp2util runtime library

add_library(cppfront_cpp2util INTERFACE)
add_library(cppfront::cpp2util ALIAS cppfront_cpp2util)
set_target_properties(cppfront_cpp2util PROPERTIES EXPORT_NAME cpp2util)

target_compile_features(cppfront_cpp2util INTERFACE cxx_std_20)
target_include_directories(
cpp2util INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
cppfront_cpp2util INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
)
target_sources(
cpp2util
cppfront_cpp2util
INTERFACE
FILE_SET HEADERS
BASE_DIRS include
FILES include/cpp2util.h
)

##
# Enable cpp2 autodetection for add_subdirectory users

if (NOT PROJECT_IS_TOP_LEVEL)
get_directory_property(_CPPFRONT_MAGIC_DIR PARENT_DIRECTORY)
include(cmake/CppfrontHelpers.cmake)
endif ()

##
# Installation and CMake packaging logic

if (CPPFRONT_INSTALL_RULES)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand All @@ -56,7 +80,7 @@ if (CPPFRONT_INSTALL_RULES)
# dependent)

install(
TARGETS cppfront
TARGETS cppfront_cppfront
EXPORT cppfront-exe-targets
COMPONENT cppfront
)
Expand Down Expand Up @@ -94,7 +118,7 @@ if (CPPFRONT_INSTALL_RULES)
# which are platform-independent

install(
TARGETS cpp2util
TARGETS cppfront_cpp2util
EXPORT cppfront-targets
FILE_SET HEADERS
COMPONENT cppfront
Expand Down