cmake: add -latomic on platforms that need it for 64-bit atomic operations

Closes #5865.
This commit is contained in:
David Adam 2019-12-20 23:00:06 +08:00
parent 3274dbacf4
commit 780bac671f
2 changed files with 14 additions and 1 deletions

View File

@ -172,7 +172,7 @@ ADD_LIBRARY(fishlib STATIC ${FISH_SRCS})
TARGET_SOURCES(fishlib PRIVATE ${FISH_HEADERS})
TARGET_LINK_LIBRARIES(fishlib
${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}
${PCRE2_LIB} ${Intl_LIBRARIES})
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY})
# Define fish.
ADD_EXECUTABLE(fish src/fish.cpp)

View File

@ -187,3 +187,16 @@ int main () {
)
FIND_PROGRAM(SED sed)
# https://github.com/fish-shell/fish-shell/issues/5865
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
struct big { int foo[64]; };
std::atomic<big> x;
int main() {
return x.load().foo[13];
}"
LIBATOMIC_NOT_NEEDED)
IF (NOT LIBATOMIC_NOT_NEEDED)
SET(ATOMIC_LIBRARY "atomic")
ENDIF()