Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[antlr4] Fix CMake files export #24157

Merged
merged 5 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 0 additions & 31 deletions ports/antlr4/fix_utfcpp_dependency.patch

This file was deleted.

131 changes: 104 additions & 27 deletions ports/antlr4/fixed_build.patch
Original file line number Diff line number Diff line change
@@ -1,38 +1,115 @@
diff -urN a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index c8b16c6..53b47dd 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -25,7 +25,7 @@
@@ -21,10 +21,13 @@ file(GLOB libantlrcpp_SRC
"${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath/*.cpp"
)

+if(BUILD_SHARED_LIBS)
add_library(antlr4_shared SHARED ${libantlrcpp_SRC})
+else()
add_library(antlr4_static STATIC ${libantlrcpp_SRC})

+endif()

-set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
+# set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
+#set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
message(STATUS "Output libraries to ${LIB_OUTPUT_DIR}")

# make sure 'make' works fine even if ${LIB_OUTPUT_DIR} is deleted.
@@ -63,15 +63,15 @@
@@ -32,16 +35,22 @@ add_custom_target(make_lib_output_dir ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_OUTPUT_DIR}
)

+if(BUILD_SHARED_LIBS)
add_dependencies(antlr4_shared make_lib_output_dir)
+else()
add_dependencies(antlr4_static make_lib_output_dir)
+endif()

find_package(utf8cpp QUIET)

set(INSTALL_utf8cpp FALSE)

if (utf8cpp_FOUND)
+ if(BUILD_SHARED_LIBS)
target_link_libraries(antlr4_shared utf8cpp)
+ else()
target_link_libraries(antlr4_static utf8cpp)
+ endif()
else()

# older utf8cpp doesn't define the package above
@@ -51,7 +60,7 @@ else()

if (utf8cpp_HEADER)
include_directories(${utf8cpp_HEADER})
- else()
+ elseif(0)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/runtime/thirdparty)
set(UTFCPP_DIR ${THIRDPARTY_DIR}/utfcpp)
@@ -76,11 +85,17 @@ else()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ if(BUILD_SHARED_LIBS)
target_link_libraries(antlr4_shared ${UUID_LIBRARIES})
+ else()
target_link_libraries(antlr4_static ${UUID_LIBRARIES})
+ endif()
elseif(APPLE)
+ if(BUILD_SHARED_LIBS)
target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY})
+ else()
target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY})
+ endif()
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@@ -102,7 +117,7 @@ if(WIN32)
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
endif(WIN32)
-if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
- if(WITH_STATIC_CRT)
- target_compile_options(antlr4_shared PRIVATE "/MT$<$<CONFIG:Debug>:d>")
- target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
- else()
- target_compile_options(antlr4_shared PRIVATE "/MD$<$<CONFIG:Debug>:d>")
- target_compile_options(antlr4_static PRIVATE "/MD$<$<CONFIG:Debug>:d>")
- endif()
-endif()
+# if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+# if(WITH_STATIC_CRT)
+# target_compile_options(antlr4_shared PRIVATE "/MT$<$<CONFIG:Debug>:d>")
+# target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
+# else()
+# target_compile_options(antlr4_shared PRIVATE "/MD$<$<CONFIG:Debug>:d>")
+# target_compile_options(antlr4_static PRIVATE "/MD$<$<CONFIG:Debug>:d>")
+# endif()
+# endif()

set(static_lib_suffix "")
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

+if(0)
if(WITH_STATIC_CRT)
target_compile_options(antlr4_shared PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
@@ -122,6 +137,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(extra_static_compile_flags "-DANTLR4CPP_STATIC -MP")
endif()

+if(BUILD_SHARED_LIBS)
set_target_properties(antlr4_shared
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
@@ -132,20 +148,25 @@ set_target_properties(antlr4_shared
RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
-
+else()
set_target_properties(antlr4_static
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
OUTPUT_NAME "antlr4-runtime${static_lib_suffix}"
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
+endif()

-install(TARGETS antlr4_shared
+if(BUILD_SHARED_LIBS)
+install(TARGETS antlr4_shared EXPORT antlr4-targets
DESTINATION lib
- EXPORT antlr4-targets)
+ RUNTIME DESTINATION bin
+ )
+else()
install(TARGETS antlr4_static
DESTINATION lib
EXPORT antlr4-targets)
+endif()

install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/"
DESTINATION "include/antlr4-runtime"
53 changes: 7 additions & 46 deletions ports/antlr4/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,22 @@ vcpkg_extract_source_archive_ex(
fixed_build.patch
uuid_discovery_fix.patch
export_guid.patch
fix_utfcpp_dependency.patch
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DANTLR4_INSTALL=ON
OPTIONS_DEBUG -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/dist
OPTIONS_RELEASE -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/dist
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME antlr4-generator CONFIG_PATH lib/cmake/antlr4-generator DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(PACKAGE_NAME antlr4-runtime CONFIG_PATH lib/cmake/antlr4-runtime)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/doc
${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/debug/include
)

if (NOT VCPKG_CMAKE_SYSTEM_NAME)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime-static.lib
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime-static.lib
)

file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.dll ${CURRENT_PACKAGES_DIR}/bin/antlr4-runtime.dll)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.dll ${CURRENT_PACKAGES_DIR}/debug/bin/antlr4-runtime.dll)
else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.lib
${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.dll
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.lib
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.dll
)

file(RENAME ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime-static.lib ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime-static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.lib)
endif()
else()
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.a
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.a
)
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL Linux)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.so
${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.so.${VERSION}
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.so
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.so.${VERSION}
)
else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.dylib
${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.${VERSION}.dylib
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.dylib
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.${VERSION}.dylib
)
endif()
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_copy_pdbs()

file(INSTALL ${LICENSE} DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${LICENSE}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
7 changes: 6 additions & 1 deletion ports/antlr4/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "antlr4",
"version": "4.9.3",
"port-version": 1,
"port-version": 2,
"description": "ANother Tool for Language Recognition",
"homepage": "https://www.antlr.org",
"license": "BSD-3-Clause",
"supports": "!uwp",
"dependencies": [
{
Expand All @@ -13,6 +14,10 @@
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
5 changes: 5 additions & 0 deletions versions/a-/antlr4.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "6a716f472a0639199a0a843a64795a88a39f5dee",
"version": "4.9.3",
"port-version": 2
},
{
"git-tree": "0a3fbd320c22b3c017fe13fb4cac5fe330c0df99",
"version": "4.9.3",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"antlr4": {
"baseline": "4.9.3",
"port-version": 1
"port-version": 2
},
"any-lite": {
"baseline": "0.4.0",
Expand Down