1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,11 +113,6 @@
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /O1 /Oi /Ob2 /Gy /MP /DNDEBUG ${MY_CXX_WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Oi /Ob2 /Gy /MP /DNDEBUG ${MY_CXX_WARNING_FLGAS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /O2 /Oi /Ob2 /Gy /MP /Zi ${MY_CXX_WARNING_FLAGS}")
-else()
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g ${MY_CXX_WARNING_FLAGS}")
- set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG ${MY_CXX_WARNING_FLAGS}")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG ${MY_CXX_WARNING_FLGAS}")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g ${MY_CXX_WARNING_FLAGS}")
endif()
# Compiler-specific C++17 activation.
@@ -220,16 +215,8 @@
endif(ANTLR4_INSTALL)
-if(EXISTS LICENSE.txt)
-install(FILES LICENSE.txt
- DESTINATION "share/doc/libantlr4")
-elseif(EXISTS ../../LICENSE.txt)
-install(FILES ../../LICENSE.txt
- DESTINATION "share/doc/libantlr4")
-endif()
-
install(FILES README.md VERSION
- DESTINATION "share/doc/libantlr4")
+ DESTINATION ${CMAKE_INSTALL_DOCDIR})
set(CPACK_PACKAGE_CONTACT "antlr-discussion@googlegroups.com")
set(CPACK_PACKAGE_VERSION ${ANTLR_VERSION})
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -26,29 +26,14 @@
)
add_library(antlr4_shared SHARED ${libantlrcpp_SRC})
-add_library(antlr4_static STATIC ${libantlrcpp_SRC})
# Make sure to link against threads (pthreads) library in order to be able to
# make use of std::call_once in the code without producing runtime errors
# (see also https://github.com/antlr/antlr4/issues/3708 and/or https://stackoverflow.com/q/51584960).
find_package(Threads REQUIRED)
target_link_libraries(antlr4_shared Threads::Threads)
-target_link_libraries(antlr4_static Threads::Threads)
if (ANTLR_BUILD_CPP_TESTS)
- include(FetchContent)
-
- FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
- )
-
- if(WITH_STATIC_CRT)
- set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
- endif()
-
- FetchContent_MakeAvailable(googletest)
-
file(GLOB libantlrcpp_TESTS
"${PROJECT_SOURCE_DIR}/runtime/tests/*.cpp"
)
@@ -60,8 +45,9 @@
target_link_libraries(
antlr4_tests
- antlr4_static
+ antlr4_shared
gtest_main
+ gtest
)
include(GoogleTest)
@@ -71,7 +57,6 @@
if(APPLE)
target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY})
- target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY})
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@@ -88,16 +73,11 @@
endif()
set(extra_share_compile_flags "")
-set(extra_static_compile_flags "")
-set(static_lib_suffix "")
if (WIN32)
- set(static_lib_suffix "-static")
target_compile_definitions(antlr4_shared PUBLIC ANTLR4CPP_EXPORTS)
- target_compile_definitions(antlr4_static PUBLIC ANTLR4CPP_STATIC)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(extra_share_compile_flags "-MP /wd4251")
- set(extra_static_compile_flags "-MP")
endif()
endif()
@@ -107,13 +87,6 @@
OUTPUT_NAME antlr4-runtime
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
-set_target_properties(antlr4_static
- PROPERTIES VERSION ${ANTLR_VERSION}
- SOVERSION ${ANTLR_VERSION}
- OUTPUT_NAME "antlr4-runtime${static_lib_suffix}"
- COMPILE_PDB_NAME "antlr4-runtime${static_lib_suffix}"
- COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
-
if (ANTLR_BUILD_CPP_TESTS)
# Copy the generated binaries to dist folder (required by test suite)
add_custom_command(
@@ -122,24 +95,12 @@
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/dist
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:antlr4_shared> ${CMAKE_HOME_DIRECTORY}/dist
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_LINKER_FILE:antlr4_shared> ${CMAKE_HOME_DIRECTORY}/dist)
-
- add_custom_command(
- TARGET antlr4_static
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/dist
- COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:antlr4_static> ${CMAKE_HOME_DIRECTORY}/dist)
endif()
install(TARGETS antlr4_shared
EXPORT antlr4-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-install(TARGETS antlr4_static
- EXPORT antlr4-targets
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/"
|