From 6dc11dccc6c8147b5b71c86be7e458eebc35f8c5 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 11 Jan 2021 14:53:31 +0800 Subject: add all the compiler specific linker flags. --- CMakeLists.txt | 5 ++++- makefile | 4 ++-- src/ghc/fs_std.hpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7374e1c..1fcb248 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ MESSAGE(STATUS "Lua library: ${LUA_LIBRARIES}") enable_language( CXX ) include_directories( src ${LUA_INCLUDE_DIR} ) -add_definitions( -std=c++17 -O3 -fPIC -lstdc++fs -ldl -Wno-unused-command-line-argument ) +add_definitions( -std=c++17 -O3 -fPIC ) add_library( libmoonp MODULE src/MoonP/ast.cpp src/MoonP/parser.cpp src/MoonP/moon_parser.cpp src/MoonP/moon_compiler.cpp src/MoonP/moonplus.cpp) set_target_properties( libmoonp PROPERTIES PREFIX "" ) @@ -35,6 +35,9 @@ target_link_libraries( libmoonp ${LUA_LIBRARIES} ) add_executable( moonp src/MoonP/ast.cpp src/MoonP/moon_compiler.cpp src/MoonP/moon_parser.cpp src/MoonP/moonplus.cpp src/MoonP/parser.cpp src/moonp.cpp ) target_link_libraries( moonp ${LUA_LIBRARIES} ) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_options( moonp PRIVATE -ldl -lpthread -lstdc++fs ) +endif() install(CODE "") diff --git a/makefile b/makefile index 963057c..1a6f2f1 100644 --- a/makefile +++ b/makefile @@ -53,7 +53,7 @@ endif # Add platform related linker flag ifneq ($(UNAME_S),Darwin) - LINK_FLAGS += -lstdc++fs + LINK_FLAGS += -lstdc++fs -Wl,-E endif # Function used to check variables. Use on the command line: @@ -268,7 +268,7 @@ all: $(BIN_PATH)/$(BIN_NAME) $(BIN_PATH)/$(BIN_NAME): $(OBJECTS) @echo "Linking: $@" @$(START_TIME) - $(CMD_PREFIX)$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ -Wl,-E + $(CMD_PREFIX)$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ @echo -en "\t Link time: " @$(END_TIME) diff --git a/src/ghc/fs_std.hpp b/src/ghc/fs_std.hpp index a38f38a..d8e03b8 100644 --- a/src/ghc/fs_std.hpp +++ b/src/ghc/fs_std.hpp @@ -30,7 +30,7 @@ // namespace fs. //--------------------------------------------------------------------------------------- #ifndef GHC_FILESYSTEM_STD_H -#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) +#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && (!defined(__GNUC__) || __GNUC__ >= 9) #if __has_include() #define GHC_USE_STD_FS #include -- cgit v1.2.3-55-g6feb