Skip to content

Commit ed28cf6

Browse files
James BarbettiJames Barbetti
James Barbetti
authored and
James Barbetti
committed
CMakeLists.txt a bit closer to working properly for Clang 15.
1 parent 2b990fc commit ed28cf6

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

CMakeLists.txt

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ project(decenttree)
6666
# Ninja from the official website, and put that somewhere in your path.
6767
# Windows VS Code GCC 9.2 The compiler mightn't have libgomp.a, libgomp.dll.a, libgomp.spec files in
6868
# its lib directory. I found I could copy them across from the 12.2 compiler's
69-
#` lib directory, to get a GCC 9.2 build to at least... link. No idea if it runs!
69+
# lib directory, to get a GCC 9.2 build to at least... link. No idea if it runs!
7070
# Windows VS COde GCC 12.2 CMake isn't recognizing the compiler. Tried installing a slightly later
7171
# CMake (3.24 rather than 3.23) but that didn't help.
7272
# Building fails due to an error message which CMake/VS Code won't display.
@@ -89,6 +89,16 @@ project(decenttree)
8989
# copy c:\msys64\usr\bin\msys-2.0.dll c:\msys64\mingw64\bin
9090
#
9191
# Mac OS Clang 13 Seems to be compiling with -std=c99 (or similar).
92+
# Mac OS Clang 15 { "name": "Clang 15.0.2",
93+
# "compilers": {
94+
# "C": "/usr/local/opt/llvm/bin/clang",
95+
# "CXX": "/usr/local/opt/llvm/bin/clang++"
96+
# },
97+
# "keep": true
98+
# },
99+
# ... had to be added to
100+
# /Users/[me]/.local/share/CMakeTools/cmake-tools-kits.json
101+
# ... because Microsoft Code wasn't finding the compiler.
92102
#
93103
#NOTE: Static linking with clang windows: make a symlink libgcc_eh.a to libgcc.a (administrator required
94104
# C:\TDM-GCC-64\lib\gcc\x86_64-w64-mingw32\5.1.0>mklink libgcc_eh.a libgcc.a
@@ -138,6 +148,19 @@ elseif (APPLE)
138148
message("Target OS : Mac OS X")
139149
message("Target System Name : ${CMAKE_HOST_SYSTEM_NAME}")
140150
message("Target System Version : ${CMAKE_HOST_SYSTEM_VERSION}")
151+
152+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
153+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER_EQUAL 13)
154+
#This doesn't look to work very well. I'm definite
155+
#that I want /usr/local/opt/llvm/lib for Clang 15 on my
156+
#Mac Wintel laptop. But find_library keeps pointing at
157+
#/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
158+
#/user/lib/libc++.tbd
159+
link_directories(/usr/local/opt/llvm/lib)
160+
find_library(CXXLIB c++ /usr/local/opt/llvm/lib)
161+
endif()
162+
endif()
163+
141164
# to be compatible back to Mac OS X 10.7
142165
if (DECENTTREE_FLAGS MATCHES "oldmac")
143166
add_definitions("-mmacosx-version-min=10.5")
@@ -255,11 +278,12 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
255278
endif()
256279

257280
# use libc++ per default in MacOS
258-
# set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -v")
281+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -v")
259282
if (APPLE)
260283
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
261284
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
262285
endif()
286+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
263287

264288
#remove -rdynamic for Clang under Linux
265289
if (UNIX AND DECENTTREE_FLAGS MATCHES "static")
@@ -437,12 +461,14 @@ if (NOT DECENTTREE_FLAGS MATCHES "single")
437461
#But I don't as yet know how to tell CMake to do that. -James B. 23-Jul-2020
438462
else()
439463
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
464+
if (APPLE)
465+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor")
466+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/bin")
467+
endif()
440468
if (APPLE OR WIN32 )
441-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -pthread")
442469
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lomp")
443-
else()
444-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread")
445-
endif()
470+
endif()
471+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread")
446472
endif()
447473
endif()
448474
else()
@@ -698,6 +724,11 @@ if (WIN32)
698724
else()
699725
#This doesn't look to be needed for clang-15 builds
700726
#set(PLATFORM_LIB "m")
727+
728+
#But this might be...
729+
if (NOT "${CXXLIB}" STREQUAL "")
730+
target_link_libraries(decenttree ${CXXLIB})
731+
endif()
701732
endif()
702733

703734
if (DECENTTREE_FLAGS MATCHES "libcxx")

0 commit comments

Comments
 (0)