Skip to content

Commit

Permalink
Add include dirs directly to defined targets
Browse files Browse the repository at this point in the history
By directly associating the defined antlr_* targets with the respective
include directories, we make sure that any user that links against one
of these targets, automatically has the necessary directories in their
include path as well (without the need to explicitly specify them) as
cmake will transitively propagate the interface include dirs to the
linked-to target.

Signed-off-by: Robert Adam <dev@robert-adam.de>
  • Loading branch information
Krzmbrzl committed May 6, 2022
1 parent 744fb9d commit 0e14115
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)

if(POLICY CMP0114)
cmake_policy(SET CMP0114 NEW)
cmake_policy(SET CMP0114 NEW)
endif()

include(ExternalProject)
Expand Down Expand Up @@ -139,6 +139,10 @@ add_library(antlr4_static STATIC IMPORTED)
add_dependencies(antlr4_static antlr4_runtime-build_static)
set_target_properties(antlr4_static PROPERTIES
IMPORTED_LOCATION ${ANTLR4_STATIC_LIBRARIES})
target_link_libraries(antlr4_static
INTERFACE
${ANTLR4_INCLUDE_DIRS}
)

ExternalProject_Add_Step(
antlr4_runtime
Expand All @@ -156,6 +160,11 @@ add_library(antlr4_shared SHARED IMPORTED)
add_dependencies(antlr4_shared antlr4_runtime-build_shared)
set_target_properties(antlr4_shared PROPERTIES
IMPORTED_LOCATION ${ANTLR4_RUNTIME_LIBRARIES})
target_link_libraries(antlr4_shared
INTERFACE
${ANTLR4_INCLUDE_DIRS}
)

if(ANTLR4_SHARED_LIBRARIES)
set_target_properties(antlr4_shared PROPERTIES
IMPORTED_IMPLIB ${ANTLR4_SHARED_LIBRARIES})
Expand Down

0 comments on commit 0e14115

Please sign in to comment.