Skip to content

Commit 928149c

Browse files
authored
Merge pull request #90 from tammela/foo
fix: link to stdc++fs when needed as discussed in #88
2 parents 2c3edd0 + ed29437 commit 928149c

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

CMakeLists.txt

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ include(CheckIPOSupported)
1414
check_ipo_supported(RESULT lto OUTPUT error)
1515

1616
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)
1919
else()
20-
message(STATUS "IPO / LTO not supported: <${error}>")
20+
message(STATUS "IPO / LTO not supported: <${error}>")
2121
endif()
2222

2323
if(NOT CMAKE_BUILD_TYPE)
@@ -28,16 +28,23 @@ endif()
2828
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Wall")
2929
set(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+
3137
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)
3643

3744
message("${var}")
3845

3946
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")
4148
endif()
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

6370
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+
)
6673

6774
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+
)
7077

7178
add_library (antlr4-cpp-runtime ${antlr4-cpp-src})
7279
add_library (yaml-cpp ${yaml-cpp-src})
@@ -80,11 +87,11 @@ endif()
8087

8188
set_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

8592
install(TARGETS lua-format
8693
RUNTIME DESTINATION bin
87-
)
94+
)
8895

8996
if(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)
114121
endif()

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Reformats your Lua source code.
1616

1717
### LuaRocks
1818

19-
The easiest way is to install is to use [LuaRocks](https://github.com/luarocks/luarocks).
19+
The easiest way to install is to use [LuaRocks](https://github.com/luarocks/luarocks).
2020

2121
```bash
2222
luarocks install --server=https://luarocks.org/dev luaformatter
@@ -27,6 +27,7 @@ luarocks install --server=https://luarocks.org/dev luaformatter
2727
#### Requirements
2828
* cmake 3.9+
2929
* c++ 17 compiler
30+
* luarocks 3.3.0+
3031

3132
#### Steps
3233
```bash

0 commit comments

Comments
 (0)