@@ -14,10 +14,10 @@ include(CheckIPOSupported)
1414check_ipo_supported(RESULT lto OUTPUT error)
1515
1616if (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 )
1919else ()
20- message (STATUS "IPO / LTO not supported: <${error} >" )
20+ message (STATUS "IPO / LTO not supported: <${error} >" )
2121endif ()
2222
2323if (NOT CMAKE_BUILD_TYPE )
@@ -28,16 +28,23 @@ endif()
2828set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Wall" )
2929set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" )
3030
31+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
32+ set (extra-libs "stdc++fs" )
33+ else ()
34+ set (extra-libs "" )
35+ endif ()
36+
3137try_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)
3643
3744message ("${var} " )
3845
3946if (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 " )
4148endif ()
4249
4350
@@ -58,15 +65,15 @@ set(src_dir
5865 ${PROJECT_SOURCE_DIR} /generated /LuaParser.cpp
5966 ${PROJECT_SOURCE_DIR} /generated /LuaVisitor.cpp
6067 ${PROJECT_SOURCE_DIR} /generated /LuaBaseVisitor.cpp
61- )
68+ )
6269
6370file (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+ )
6673
6774file (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+ )
7077
7178add_library (antlr4-cpp-runtime ${antlr4-cpp-src})
7279add_library (yaml-cpp ${yaml-cpp-src})
@@ -80,11 +87,11 @@ endif()
8087
8188set_target_properties (lua-format PROPERTIES LINKER_LANGUAGE CXX)
8289
83- target_link_libraries (lua-format yaml-cpp antlr4-cpp-runtime)
90+ target_link_libraries (lua-format yaml-cpp antlr4-cpp-runtime ${extra-libs} )
8491
8592install (TARGETS lua-format
8693 RUNTIME DESTINATION bin
87- )
94+ )
8895
8996if (BUILD_TESTS)
9097 message ("BUILD_TESTS enabled." )
@@ -96,7 +103,7 @@ if(BUILD_TESTS)
96103 test /test_config.cpp
97104 test /test_format_file.cpp
98105 test /test_parser.cpp
99- )
106+ )
100107 set_target_properties (lua-format-test PROPERTIES LINKER_LANGUAGE CXX)
101108
102109 if (COVERAGE AND CMAKE_BUILD_TYPE MATCHES "Debug" )
@@ -108,7 +115,7 @@ if(BUILD_TESTS)
108115 endif ()
109116
110117 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} )
112119
113120 add_test (all_tests lua-format-test )
114121endif ()
0 commit comments