@@ -14,10 +14,10 @@ include(CheckIPOSupported)
14
14
check_ipo_supported(RESULT lto OUTPUT error)
15
15
16
16
if (lto)
17
- message (STATUS "IPO / LTO enabled" )
18
- set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE )
17
+ message (STATUS "IPO / LTO enabled" )
18
+ set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE )
19
19
else ()
20
- message (STATUS "IPO / LTO not supported: <${error} >" )
20
+ message (STATUS "IPO / LTO not supported: <${error} >" )
21
21
endif ()
22
22
23
23
if (NOT CMAKE_BUILD_TYPE )
@@ -28,16 +28,23 @@ endif()
28
28
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Wall" )
29
29
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" )
30
30
31
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
32
+ set (extra-libs "stdc++fs" )
33
+ else ()
34
+ set (extra-libs "" )
35
+ endif ()
36
+
31
37
try_run (TEST_RUN_RESULT
32
- TEST_COMPILE_RESULT
33
- ${CMAKE_CURRENT_BINARY_DIR} /
34
- ${PROJECT_SOURCE_DIR} /test /cpp17/fs.cpp
35
- OUTPUT_VARIABLE var)
38
+ TEST_COMPILE_RESULT
39
+ ${CMAKE_CURRENT_BINARY_DIR} /
40
+ ${PROJECT_SOURCE_DIR} /test /cpp17/fs.cpp
41
+ LINK_LIBRARIES ${extra-libs}
42
+ OUTPUT_VARIABLE var)
36
43
37
44
message ("${var} " )
38
45
39
46
if (NOT "${TEST_COMPILE_RESULT} " OR (NOT "${TEST_RUN_RESULT} " EQUAL 0))
40
- message (FATAL_ERROR "Your compiler does not fully support the C++17 standard" )
47
+ message (FATAL_ERROR "Your compiler does not fully support the C++17 standard and libraries " )
41
48
endif ()
42
49
43
50
@@ -58,15 +65,15 @@ set(src_dir
58
65
${PROJECT_SOURCE_DIR} /generated /LuaParser.cpp
59
66
${PROJECT_SOURCE_DIR} /generated /LuaVisitor.cpp
60
67
${PROJECT_SOURCE_DIR} /generated /LuaBaseVisitor.cpp
61
- )
68
+ )
62
69
63
70
file (GLOB_RECURSE antlr4-cpp-src
64
- ${PROJECT_SOURCE_DIR} /third_party/antlr4/runtime/Cpp/runtime/src/*.cpp
65
- )
71
+ ${PROJECT_SOURCE_DIR} /third_party/antlr4/runtime/Cpp/runtime/src/*.cpp
72
+ )
66
73
67
74
file (GLOB_RECURSE yaml-cpp-src
68
- ${PROJECT_SOURCE_DIR} /third_party/yaml-cpp/src/*.cpp
69
- )
75
+ ${PROJECT_SOURCE_DIR} /third_party/yaml-cpp/src/*.cpp
76
+ )
70
77
71
78
add_library (antlr4-cpp-runtime ${antlr4-cpp-src})
72
79
add_library (yaml-cpp ${yaml-cpp-src})
@@ -80,11 +87,11 @@ endif()
80
87
81
88
set_target_properties (lua-format PROPERTIES LINKER_LANGUAGE CXX)
82
89
83
- target_link_libraries (lua-format yaml-cpp antlr4-cpp-runtime)
90
+ target_link_libraries (lua-format yaml-cpp antlr4-cpp-runtime ${extra-libs} )
84
91
85
92
install (TARGETS lua-format
86
93
RUNTIME DESTINATION bin
87
- )
94
+ )
88
95
89
96
if (BUILD_TESTS)
90
97
message ("BUILD_TESTS enabled." )
@@ -96,7 +103,7 @@ if(BUILD_TESTS)
96
103
test /test_config.cpp
97
104
test /test_format_file.cpp
98
105
test /test_parser.cpp
99
- )
106
+ )
100
107
set_target_properties (lua-format-test PROPERTIES LINKER_LANGUAGE CXX)
101
108
102
109
if (COVERAGE AND CMAKE_BUILD_TYPE MATCHES "Debug" )
@@ -108,7 +115,7 @@ if(BUILD_TESTS)
108
115
endif ()
109
116
110
117
target_compile_definitions (lua-format-test PUBLIC PROJECT_PATH="${PROJECT_SOURCE_DIR} " )
111
- target_link_libraries (lua-format-test yaml-cpp antlr4-cpp-runtime)
118
+ target_link_libraries (lua-format-test yaml-cpp antlr4-cpp-runtime ${extra-libs} )
112
119
113
120
add_test (all_tests lua-format-test )
114
121
endif ()
0 commit comments