I am trying (well, failing, really) to build VS project files using CMake and Ninja with the following command on Windows 10 (using Clang as the compiler and VS2019).
-- The C compiler identification is Clang 11.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 11.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64/python.exe (found version "3.7.8") found components: Interpreter
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring juceaide
CMake Error at JUCE/extras/Build/juceaide/CMakeLists.txt:76 (message):
Failed to configure juceaide
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:30 (project):
No CMAKE_C_COMPILER could be found.
It seems that CMake is finding the compilers initially, then not finding them when building juceaide.
It is quite possible (ok, probable) that I am doing something wildly incorrect, but I’m a bit of a Windows neophyte and my CMake knowledge is incomplete. Can anyone offer any suggestions on how I can get CMake to succeed with these tools?
In our CI, our GNU-Clang and Ninja build sets the following environment variables:
RC = llvm-rc.exe
CC = clang.exe
CXX = clang++.exe
It also adds the Tools/LLvm/bin directory to the PATH environment variable before the build. Finally, it adds the flag -fuse-ld=lld-link.exe to the CMAKE_CXX_FLAGS, because otherwise the build would use the MSVC linker, which doesn’t seem to be compatible with LLVM LTO.
If you don’t mind giving up Ninja, the Visual Studio exporter is a bit easier to get running with clang. You should be able to just cmake -G "Visual Studio 16 2019" -T ClangCL -A x64 and get a working clang build.
@reukThank you much. I got it working (not sure how I did not add those env variables…seems kind of obvious now ).
I ended up keeping Ninja which isn’t a requirement now, but will be at some point.
Anyway, I did get some warnings so I thought I should let you know. On first glance, they appear to all be related to conversions between data types. See below.
(Note: plug-Example and plug-Example_tests are what is built.)
In file included from ../JUCE/modules/juce_events/juce_events.cpp:83:
../JUCE/modules/juce_events/native/juce_win32_Messaging.cpp:72:61: warning: implicit conversion loses integer precision: 'unsigned long long' to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
data.cbData = ((size_t) localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType);
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[25/83] Building CXX object plug-Example/plug/CMakeFiles/plug-Example_tests.dir/__/__/JUCE/modules/juce_events/juce_events.cpp.obj
In file included from ../JUCE/modules/juce_events/juce_events.cpp:83:
../JUCE/modules/juce_events/native/juce_win32_Messaging.cpp:72:61: warning: implicit conversion loses integer precision: 'unsigned long long' to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
data.cbData = ((size_t) localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType);
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[26/83] Building CXX object plug-Example/plug/CMakeFiles/plug-Example.dir/__/__/JUCE/modules/juce_core/juce_core.cpp.obj
In file included from ../JUCE/modules/juce_core/juce_core.cpp:219:
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:46:32: warning: cast from 'std::aligned_storage<44, 4>::type *' (aka '_Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *'
(aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
InitializeCriticalSection ((CRITICAL_SECTION*) &lock);
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:49:78: warning: cast from 'std::aligned_storage<44, 4>::type *' (aka '_Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *'
(aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
CriticalSection::~CriticalSection() noexcept { DeleteCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:50:77: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
void CriticalSection::enter() const noexcept { EnterCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:51:87: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
bool CriticalSection::tryEnter() const noexcept { return TryEnterCriticalSection ((CRITICAL_SECTION*) &lock) != FALSE; }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:52:77: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
void CriticalSection::exit() const noexcept { LeaveCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
[32/83] Building CXX object plug-Example/plug/CMakeFiles/plug-Example_tests.dir/__/__/JUCE/modules/juce_core/juce_core.cpp.obj
In file included from ../JUCE/modules/juce_core/juce_core.cpp:219:
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:46:32: warning: cast from 'std::aligned_storage<44, 4>::type *' (aka '_Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *'
(aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
InitializeCriticalSection ((CRITICAL_SECTION*) &lock);
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:49:78: warning: cast from 'std::aligned_storage<44, 4>::type *' (aka '_Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *'
(aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
CriticalSection::~CriticalSection() noexcept { DeleteCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:50:77: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
void CriticalSection::enter() const noexcept { EnterCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:51:87: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
bool CriticalSection::tryEnter() const noexcept { return TryEnterCriticalSection ((CRITICAL_SECTION*) &lock) != FALSE; }
^~~~~~~~~~~~~~~~~~~~~~~~~
../JUCE/modules/juce_core/native/juce_win32_Threads.cpp:52:77: warning: cast from 'const std::aligned_storage<44, 4>::type *' (aka 'const _Align_type<int, 44ULL> *') to 'CRITICAL_SECTION *' (aka '_RTL_CRITICAL_SECTION *') increases required alignment from 4 to 8 [-Wcast-align]
void CriticalSection::exit() const noexcept { LeaveCriticalSection ((CRITICAL_SECTION*) &lock); }
^~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
[78/83] Building CXX object plug-Example/plug/CMakeFiles/plug-Example_tests.dir/__/__/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp.obj
In file included from ../JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:128:
../JUCE/modules/juce_gui_basics/components/juce_FocusTraverser.cpp:61:52: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
return getComponentOrderAttributes (a) < getComponentOrderAttributes (b);
^
nullptr
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\tuple:759:97: note: while rewriting comparison as call to 'operator<=>' declared here
_NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Types1, _Types2>...> operator<=>(
^
../JUCE/modules/juce_gui_basics/components/juce_FocusTraverser.cpp:141:23: note: in instantiation of function template specialization 'juce::FocusHelpers::findAllComponents<bool
(juce::Component::*)() const noexcept>' requested here
FocusHelpers::findAllComponents (parentComponent,
^
1 warning generated.
Thanks for letting me know. It looks like I might have missed some warnings when building in 64-bit mode rather than 32-bit. I’ll put this on my backlog and update the thread once these are fixed.
Hi again @reuk
Ran into this one today (Windows again).
In file included from ../JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:128:
../JUCE/modules/juce_gui_basics/components/juce_FocusTraverser.cpp:61:52: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
return getComponentOrderAttributes (a) < getComponentOrderAttributes (b);
^
nullptr
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\tuple:759:97: note: while rewriting comparison as call to 'operator<=>' declared here
_NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Types1, _Types2>...> operator<=>(
^
../JUCE/modules/juce_gui_basics/components/juce_FocusTraverser.cpp:141:23: note: in instantiation of function template specialization 'juce::FocusHelpers::findAllComponents<bool (juce::Component::*)() const noexcept>' requested here
FocusHelpers::findAllComponents (parentComponent,
^
1 warning generated.