LLVM Discussion Forums

Windows LLVM binary with LLVM C++ API

We want to build a project (LLVM C backend) that needs LVM C++ API for building.

However, on Windows using the binaries provided in https://releases.llvm.org/download.html#10.0.0, we get this error: Unknown CMake command "add_llvm_library".

For example,

using Clang with MinGW Makefiles
The C compiler identification is Clang 10.0.0 with GNU-like command-line
The CXX compiler identification is Clang 10.0.0 with GNU-like command-line
Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at lib/Target/CBackend/TargetInfo/CMakeLists.txt:10 (add_llvm_library):
  Unknown CMake command "add_llvm_library".
or using Clang with Visual Studio:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is Clang 10.0.0 with MSVC-like command-line
The CXX compiler identification is Clang 10.0.0 with MSVC-like command-line
Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe
Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at lib/Target/CBackend/TargetInfo/CMakeLists.txt:10 (add_llvm_library):
  Unknown CMake command "add_llvm_library".
or solely using Visual Studio:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.25.28614.0
The CXX compiler identification is MSVC 19.25.28614.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at lib/Target/CBackend/TargetInfo/CMakeLists.txt:10 (add_llvm_library):
  Unknown CMake command "add_llvm_library".

How can we solve this issue?

This only happens on Windows and macOS and Ubuntu are fine.

Building LLVM from scratch is very hard and impossible for most of our users.

Hi aminya,

Could you paste the full output from your CMake script when run on Windows? And how do you install LLVM?

I’m not a Windows user so I can’t verify this, but my initial guess would be that either:

  • your LLVM package doesn’t contain the bits required for development (header files, CMake scripts)
  • or, perhaps, you do have the required installation, but when invoking CMake it is not finding it

In your CMake script you may also prefer to be a bit more explicit, i.e. use find_package(LLVM 10.0.0 REQUIRED CONFIG) instead of find_package(LLVM REQUIRED CONFIG). This way you are confident that you’re using LLVM 10.

Hope this helps!
Andrzej

1 Like

I literally used the binary from llvm.org so if it doesn’t include the header files, etc, there should be an easy way to install them other than building from scratch like how every other OS can.

This is:

the output from cmake-gui
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

The C compiler identification is Clang 10.0.0 with GNU-like command-line
The CXX compiler identification is Clang 10.0.0 with GNU-like command-line
Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe
Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at lib/Target/CBackend/TargetInfo/CMakeLists.txt:10 (add_llvm_library):
  Unknown CMake command "add_llvm_library".


Configuring incomplete, errors occurred!
See also "C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeOutput.log".
and here the CMakeOutput.log
The system is: Windows - 10.0.18363 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Program Files/LLVM/bin/clang.exe 
Build flags: 
Id flags:  

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.exe"

The C compiler identification is Clang, found in "C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/3.17.1/CompilerIdC/a.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files/LLVM/bin/clang++.exe 
Build flags: 
Id flags:  

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"

The CXX compiler identification is Clang, found in "C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/3.17.1/CompilerIdCXX/a.exe"

Determining if the C compiler works passed with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_621e7/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_621e7.dir\build.make CMakeFiles/cmTC_621e7.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_621e7.dir/testCCompiler.c.obj

C:\PROGRA~1\LLVM\bin\clang.exe   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -o CMakeFiles\cmTC_621e7.dir\testCCompiler.c.obj   -c "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\testCCompiler.c"

Linking C executable cmTC_621e7.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_621e7.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_621e7.dir\objects1.rsp  -o cmTC_621e7.exe -Xlinker /implib:cmTC_621e7.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_621e7.pdb" -Xlinker /version:0.0  @CMakeFiles\cmTC_621e7.dir\linklibs.rsp
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'




Detecting C compiler ABI info compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_7fe9f/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_7fe9f.dir\build.make CMakeFiles/cmTC_7fe9f.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_7fe9f.dir/CMakeCCompilerABI.c.obj

C:\PROGRA~1\LLVM\bin\clang.exe   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -o CMakeFiles\cmTC_7fe9f.dir\CMakeCCompilerABI.c.obj   -c "C:\Program Files\CMake\share\cmake-3.17\Modules\CMakeCCompilerABI.c"

Linking C executable cmTC_7fe9f.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_7fe9f.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_7fe9f.dir\objects1.rsp  -o cmTC_7fe9f.exe -Xlinker /implib:cmTC_7fe9f.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_7fe9f.pdb" -Xlinker /version:0.0  
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'




Determining if the CXX compiler works passed with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_d9392/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_d9392.dir\build.make CMakeFiles/cmTC_d9392.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_d9392.dir/testCXXCompiler.cxx.obj

C:\PROGRA~1\LLVM\bin\clang++.exe    -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -o CMakeFiles\cmTC_d9392.dir\testCXXCompiler.cxx.obj -c "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx"

Linking CXX executable cmTC_d9392.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_d9392.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_d9392.dir\objects1.rsp  -o cmTC_d9392.exe -Xlinker /implib:cmTC_d9392.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_d9392.pdb" -Xlinker /version:0.0  @CMakeFiles\cmTC_d9392.dir\linklibs.rsp
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'




Detecting CXX compiler ABI info compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_f9a8a/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_f9a8a.dir\build.make CMakeFiles/cmTC_f9a8a.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_f9a8a.dir/CMakeCXXCompilerABI.cpp.obj

C:\PROGRA~1\LLVM\bin\clang++.exe    -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -o CMakeFiles\cmTC_f9a8a.dir\CMakeCXXCompilerABI.cpp.obj -c "C:\Program Files\CMake\share\cmake-3.17\Modules\CMakeCXXCompilerABI.cpp"

Linking CXX executable cmTC_f9a8a.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_f9a8a.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_f9a8a.dir\objects1.rsp  -o cmTC_f9a8a.exe -Xlinker /implib:cmTC_f9a8a.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_f9a8a.pdb" -Xlinker /version:0.0  
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'






Detecting CXX [-std=c++14] compiler features compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_3c424/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_3c424.dir\build.make CMakeFiles/cmTC_3c424.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_3c424.dir/feature_tests.cxx.obj

C:\PROGRA~1\LLVM\bin\clang++.exe    -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -std=c++14 -o CMakeFiles\cmTC_3c424.dir\feature_tests.cxx.obj -c "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\feature_tests.cxx"

Linking CXX executable cmTC_3c424.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_3c424.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_3c424.dir\objects1.rsp  -o cmTC_3c424.exe -Xlinker /implib:cmTC_3c424.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_3c424.pdb" -Xlinker /version:0.0  @CMakeFiles\cmTC_3c424.dir\linklibs.rsp
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'




    Feature record: CXX_FEATURE:1cxx_template_template_parameters
    Feature record: CXX_FEATURE:1cxx_alias_templates
    Feature record: CXX_FEATURE:1cxx_alignas
    Feature record: CXX_FEATURE:1cxx_alignof
    Feature record: CXX_FEATURE:1cxx_attributes
    Feature record: CXX_FEATURE:1cxx_auto_type
    Feature record: CXX_FEATURE:1cxx_constexpr
    Feature record: CXX_FEATURE:1cxx_decltype
    Feature record: CXX_FEATURE:1cxx_default_function_template_args
    Feature record: CXX_FEATURE:1cxx_defaulted_functions
    Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers
    Feature record: CXX_FEATURE:1cxx_delegating_constructors
    Feature record: CXX_FEATURE:1cxx_deleted_functions
    Feature record: CXX_FEATURE:1cxx_enum_forward_declarations
    Feature record: CXX_FEATURE:1cxx_explicit_conversions
    Feature record: CXX_FEATURE:1cxx_extended_friend_declarations
    Feature record: CXX_FEATURE:1cxx_extern_templates
    Feature record: CXX_FEATURE:1cxx_final
    Feature record: CXX_FEATURE:1cxx_func_identifier
    Feature record: CXX_FEATURE:1cxx_generalized_initializers
    Feature record: CXX_FEATURE:1cxx_inheriting_constructors
    Feature record: CXX_FEATURE:1cxx_inline_namespaces
    Feature record: CXX_FEATURE:1cxx_lambdas
    Feature record: CXX_FEATURE:1cxx_local_type_template_args
    Feature record: CXX_FEATURE:1cxx_long_long_type
    Feature record: CXX_FEATURE:1cxx_noexcept
    Feature record: CXX_FEATURE:1cxx_nonstatic_member_init
    Feature record: CXX_FEATURE:1cxx_nullptr
    Feature record: CXX_FEATURE:1cxx_override
    Feature record: CXX_FEATURE:1cxx_range_for
    Feature record: CXX_FEATURE:1cxx_raw_string_literals
    Feature record: CXX_FEATURE:1cxx_reference_qualified_functions
    Feature record: CXX_FEATURE:1cxx_right_angle_brackets
    Feature record: CXX_FEATURE:1cxx_rvalue_references
    Feature record: CXX_FEATURE:1cxx_sizeof_member
    Feature record: CXX_FEATURE:1cxx_static_assert
    Feature record: CXX_FEATURE:1cxx_strong_enums
    Feature record: CXX_FEATURE:1cxx_thread_local
    Feature record: CXX_FEATURE:1cxx_trailing_return_types
    Feature record: CXX_FEATURE:1cxx_unicode_literals
    Feature record: CXX_FEATURE:1cxx_uniform_initialization
    Feature record: CXX_FEATURE:1cxx_unrestricted_unions
    Feature record: CXX_FEATURE:1cxx_user_literals
    Feature record: CXX_FEATURE:1cxx_variadic_macros
    Feature record: CXX_FEATURE:1cxx_variadic_templates
    Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers
    Feature record: CXX_FEATURE:1cxx_attribute_deprecated
    Feature record: CXX_FEATURE:1cxx_binary_literals
    Feature record: CXX_FEATURE:1cxx_contextual_conversions
    Feature record: CXX_FEATURE:1cxx_decltype_auto
    Feature record: CXX_FEATURE:1cxx_digit_separators
    Feature record: CXX_FEATURE:1cxx_generic_lambdas
    Feature record: CXX_FEATURE:1cxx_lambda_init_captures
    Feature record: CXX_FEATURE:1cxx_relaxed_constexpr
    Feature record: CXX_FEATURE:1cxx_return_type_deduction
    Feature record: CXX_FEATURE:1cxx_variable_templates


Detecting CXX [-std=c++14] compiler features compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_fbfcc/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make  -f CMakeFiles\cmTC_fbfcc.dir\build.make CMakeFiles/cmTC_fbfcc.dir/build

mingw32-make[1]: Entering directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_fbfcc.dir/feature_tests.cxx.obj

C:\PROGRA~1\LLVM\bin\clang++.exe    -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd   -std=c++14 -o CMakeFiles\cmTC_fbfcc.dir\feature_tests.cxx.obj -c "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\feature_tests.cxx"

Linking CXX executable cmTC_fbfcc.exe

"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_fbfcc.dir\link.txt --verbose=1

C:\PROGRA~1\LLVM\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib   -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd    @CMakeFiles\cmTC_fbfcc.dir\objects1.rsp  -o cmTC_fbfcc.exe -Xlinker /implib:cmTC_fbfcc.lib -Xlinker /pdb:"C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\cmTC_fbfcc.pdb" -Xlinker /version:0.0  @CMakeFiles\cmTC_fbfcc.dir\linklibs.rsp
mingw32-make[1]: Leaving directory 'C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp'




    Feature record: CXX_FEATURE:1cxx_template_template_parameters
    Feature record: CXX_FEATURE:1cxx_alias_templates
    Feature record: CXX_FEATURE:1cxx_alignas
    Feature record: CXX_FEATURE:1cxx_alignof
    Feature record: CXX_FEATURE:1cxx_attributes
    Feature record: CXX_FEATURE:1cxx_auto_type
    Feature record: CXX_FEATURE:1cxx_constexpr
    Feature record: CXX_FEATURE:1cxx_decltype
    Feature record: CXX_FEATURE:1cxx_default_function_template_args
    Feature record: CXX_FEATURE:1cxx_defaulted_functions
    Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers
    Feature record: CXX_FEATURE:1cxx_delegating_constructors
    Feature record: CXX_FEATURE:1cxx_deleted_functions
    Feature record: CXX_FEATURE:1cxx_enum_forward_declarations
    Feature record: CXX_FEATURE:1cxx_explicit_conversions
    Feature record: CXX_FEATURE:1cxx_extended_friend_declarations
    Feature record: CXX_FEATURE:1cxx_extern_templates
    Feature record: CXX_FEATURE:1cxx_final
    Feature record: CXX_FEATURE:1cxx_func_identifier
    Feature record: CXX_FEATURE:1cxx_generalized_initializers
    Feature record: CXX_FEATURE:1cxx_inheriting_constructors
    Feature record: CXX_FEATURE:1cxx_inline_namespaces
    Feature record: CXX_FEATURE:1cxx_lambdas
    Feature record: CXX_FEATURE:1cxx_local_type_template_args
    Feature record: CXX_FEATURE:1cxx_long_long_type
    Feature record: CXX_FEATURE:1cxx_noexcept
    Feature record: CXX_FEATURE:1cxx_nonstatic_member_init
    Feature record: CXX_FEATURE:1cxx_nullptr
    Feature record: CXX_FEATURE:1cxx_override
    Feature record: CXX_FEATURE:1cxx_range_for
    Feature record: CXX_FEATURE:1cxx_raw_string_literals
    Feature record: CXX_FEATURE:1cxx_reference_qualified_functions
    Feature record: CXX_FEATURE:1cxx_right_angle_brackets
    Feature record: CXX_FEATURE:1cxx_rvalue_references
    Feature record: CXX_FEATURE:1cxx_sizeof_member
    Feature record: CXX_FEATURE:1cxx_static_assert
    Feature record: CXX_FEATURE:1cxx_strong_enums
    Feature record: CXX_FEATURE:1cxx_thread_local
    Feature record: CXX_FEATURE:1cxx_trailing_return_types
    Feature record: CXX_FEATURE:1cxx_unicode_literals
    Feature record: CXX_FEATURE:1cxx_uniform_initialization
    Feature record: CXX_FEATURE:1cxx_unrestricted_unions
    Feature record: CXX_FEATURE:1cxx_user_literals
    Feature record: CXX_FEATURE:1cxx_variadic_macros
    Feature record: CXX_FEATURE:1cxx_variadic_templates
    Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers
    Feature record: CXX_FEATURE:1cxx_attribute_deprecated
    Feature record: CXX_FEATURE:1cxx_binary_literals
    Feature record: CXX_FEATURE:1cxx_contextual_conversions
    Feature record: CXX_FEATURE:1cxx_decltype_auto
    Feature record: CXX_FEATURE:1cxx_digit_separators
    Feature record: CXX_FEATURE:1cxx_generic_lambdas
    Feature record: CXX_FEATURE:1cxx_lambda_init_captures
    Feature record: CXX_FEATURE:1cxx_relaxed_constexpr
    Feature record: CXX_FEATURE:1cxx_return_type_deduction
    Feature record: CXX_FEATURE:1cxx_variable_templates


Using this I still get the same error.

Using only Visual Studio, the full log is a little different

CMakeOutput.log
The system is: Windows - 10.0.18363 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler:  
Build flags: 
Id flags:  

The output was:
0
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2020-04-27 5:34:18 AM.
Project "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc142.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
  CMakeCCompilerId.c
Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
  CompilerIdC.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdC\.\CompilerIdC.exe
PostBuildEvent:
  for %%i in (cl.exe) do @echo CMAKE_C_COMPILER=%%~$PATH:i
  :VCEnd
  CMAKE_C_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\cl.exe
FinalizeBuildStatus:
  Deleting file "Debug\CompilerIdC.tlog\unsuccessfulbuild".
  Touching "Debug\CompilerIdC.tlog\CompilerIdC.lastbuildstate".
Done Building Project "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdC\CompilerIdC.vcxproj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.40


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.exe"

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.vcxproj"

The C compiler identification is MSVC, found in "C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/3.17.1/CompilerIdC/CompilerIdC.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler:  
Build flags: 
Id flags:  

The output was:
0
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2020-04-27 5:34:22 AM.
Project "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc142.pdb" /Gd /TP /FC /errorReport:queue CMakeCXXCompilerId.cpp
  CMakeCXXCompilerId.cpp
Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
  CompilerIdCXX.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdCXX\.\CompilerIdCXX.exe
PostBuildEvent:
  for %%i in (cl.exe) do @echo CMAKE_CXX_COMPILER=%%~$PATH:i
  :VCEnd
  CMAKE_CXX_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\cl.exe
FinalizeBuildStatus:
  Deleting file "Debug\CompilerIdCXX.tlog\unsuccessfulbuild".
  Touching "Debug\CompilerIdCXX.tlog\CompilerIdCXX.lastbuildstate".
Done Building Project "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\3.17.1\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.67


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe"

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.vcxproj"

The CXX compiler identification is MSVC, found in "C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/3.17.1/CompilerIdCXX/CompilerIdCXX.exe"

Determining if the C compiler works passed with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/MSBuild/Current/Bin/MSBuild.exe cmTC_3b51d.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_3b51d.dir\Debug\\" /Fd"cmTC_3b51d.dir\Debug\vc142.pdb" /Gd /TC /errorReport:queue "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\testCCompiler.c"

  testCCompiler.c

  cmTC_3b51d.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\Debug\cmTC_3b51d.exe




Detecting C compiler ABI info compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/MSBuild/Current/Bin/MSBuild.exe cmTC_4365b.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_4365b.dir\Debug\\" /Fd"cmTC_4365b.dir\Debug\vc142.pdb" /Gd /TC /errorReport:queue "C:\Program Files\CMake\share\cmake-3.17\Modules\CMakeCCompilerABI.c"

  CMakeCCompilerABI.c

  cmTC_4365b.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\Debug\cmTC_4365b.exe




Determining if the CXX compiler works passed with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/MSBuild/Current/Bin/MSBuild.exe cmTC_e7811.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_e7811.dir\Debug\\" /Fd"cmTC_e7811.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue "C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx"

  testCXXCompiler.cxx

  cmTC_e7811.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\Debug\cmTC_e7811.exe




Detecting CXX compiler ABI info compiled with the following output:
Change Dir: C:/Program Files/LLVM/projects/llvm-cbe/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/MSBuild/Current/Bin/MSBuild.exe cmTC_bf550.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_bf550.dir\Debug\\" /Fd"cmTC_bf550.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue "C:\Program Files\CMake\share\cmake-3.17\Modules\CMakeCXXCompilerABI.cpp"

  CMakeCXXCompilerABI.cpp

  cmTC_bf550.vcxproj -> C:\Program Files\LLVM\projects\llvm-cbe\build\CMakeFiles\CMakeTmp\Debug\cmTC_bf550.exe





Hi aminya,

Sorry for the delay and cheers for your quick reply! Also, you did specify where you got LLVM from in your original question - my bad for not noticing!

AFAIR (I only used them once, a while ago, i.e. before LLVM 10), the Windows packages from https://releases.llvm.org/download.html contained only binaries and libraries to develop with LLVM. One relatively easy check is to look for LLVMConfig.cmake in the installation directory. If it’s not there then you may need to look for LLVM elsewhere or submit a bugzilla ticket.

If LLVMConfig.cmake is available then I’d experiment with your CMakeLists.txt a bit more. In particular, it contains this:

  find_package(LLVM REQUIRED CONFIG)
  message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
  message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

However, these messages are not printed in the log from cmake-gui that you posted. This suggests to me that find_package was not run at all (hence LLVM’s CMake scripts have not been loaded and as a result add_llvm_library is not available.

I hope that this helps. Again, it is tricky without testing on an actual Windows machine.

-Andrzej

1 Like

Thanks for the answer and sorry for the late response.

Is there an LLVMConfig.cmake I can download from somewhere?

In Linux releases, there is an llvm-config executable that gives all the paths, but this does not exist in Windows!

Writing my own LLVMConfig will not help, because it needs to include LLVM_definitions as well.

Any solution for this?

Hi,aminya , Have you solved your problem?The same error occurred when I used the Cmake GUI on Windows.

I tried to replacing add_llvm_library with add_library, the error is no longer displayed. You can try it.