When trying to use the Llvm_analysis module in the Llvm package, I get the error message:
File "_none_", line 1:
Error: No implementations provided for the following modules:
Llvm_analysis referenced from .compiler.eobjs/native/dune__exe__Codegen.cmx
Is this an error on my end or is something wrong with the llvm package?
Dune file is:
(executable
(name compiler)
(modes byte exe)
(libraries base stdio sexp_pretty str parsexp llvm)
(preprocess (pps ppx_jane ppx_regexp))
)
The llvm library is packaged into several subpackages, e.g.,
$ ocamlfind list | grep llvm
llvm (version: 9.0.0)
llvm.all_backends (version: 9.0.0)
llvm.analysis (version: 9.0.0)
llvm.bitreader (version: 9.0.0)
llvm.bitwriter (version: 9.0.0)
llvm.executionengine (version: 9.0.0)
llvm.ipo (version: 9.0.0)
llvm.irreader (version: 9.0.0)
llvm.linker (version: 9.0.0)
llvm.passmgr_builder (version: 9.0.0)
llvm.scalar_opts (version: 9.0.0)
llvm.target (version: 9.0.0)
llvm.transform_utils (version: 9.0.0)
llvm.vectorize (version: 9.0.0)
llvm_AArch64 (version: 9.0.0)
llvm_AMDGPU (version: 9.0.0)
llvm_ARM (version: 9.0.0)
llvm_BPF (version: 9.0.0)
llvm_Hexagon (version: 9.0.0)
llvm_Lanai (version: 9.0.0)
llvm_MSP430 (version: 9.0.0)
llvm_Mips (version: 9.0.0)
llvm_NVPTX (version: 9.0.0)
llvm_PowerPC (version: 9.0.0)
llvm_RISCV (version: 9.0.0)
llvm_Sparc (version: 9.0.0)
llvm_SystemZ (version: 9.0.0)
llvm_X86 (version: 9.0.0)
llvm_XCore (version: 9.0.0)
The llvm package is only the base library, to enable Llvm_analysis you need to link to the llvm.analysis (i.e., add it to the libraries stanza of your dune file.
Related
I'm trying to execute my homework in C++ with OpenMP on Mac with macOS Mojave. But it's failed. The Mac is new, so all setups are not changed. What I did:
I installed Homebrew.
I installed llvm (brew install llvm)
I installed omp (brew install libomp)
Also, in CMakeLists.txt of the project I have
cmake_minimum_required(VERSION 3.5.1)
project(...)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fopenmp -O3")
add_executable(...)
In Terminal 'clang -v':
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
'gcc -v':
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
In CLion I have this error:
[ 25%] Linking CXX executable search
ld: unknown option: -platform_version
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [search] Error 1
make[2]: *** [CMakeFiles/search.dir/all] Error 2
make[1]: *** [CMakeFiles/search.dir/rule] Error 2
make: *** [search] Error 2
I re-read a lot of forums, but I still don’t understand what the problem may be.
Be sure to call the Xcode preprocessor to handle OMP.
C++ flags should include:
-Xpreprocessor -fopenmp -lomp -I/usr/local/include
LDFLAGS should include:
-lomp
With cmake you may add them to your command:
cmake -DCMAKE_CXX_FLAGS="-Xpreprocessor -fopenmp -lomp -I/usr/local/include" -DCMAKE_EXE_LINKER_FLAGS="-lomp" ..
or you may add them to your CMakeLists.txt
After trying so many options from the following links
How to set up basic openMP project in CLion
How to set linker flags for OpenMP in CMake's try_compile function
.. and some more
I had the error The CMAKE_CXX_COMPILER: g++-6 is not a full path and was not found in the PATH.
So
i installed GNU gcc from brew instead of Clang (gcc#12 was installed)
brew install gcc
Changed the c++ and c compilers in Preferences > Build, Execution and Development > Toolchains in CLion to the installed compilers in 1
/usr/local/bin/gcc-12 // c
/usr/local/bin/g++-12 // c++
My CMakeList.txt file at this point looks like this:
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 11)
add_executable(test main.cpp)
target_compile_options(test PRIVATE -Wall ${OpenMP_CXX_FLAGS})
target_link_libraries(test PRIVATE ${OpenMP_CXX_FLAGS})
and it worked for me.
I'm working on a C++ CMake project that uses Apache Arrow as a dependency. My goal is to be able to include and use arrow/api.h. However, I couldn't find any documentation or tutorial that explains what I can do to achieve that so my first thought was to add it as a third library using CMake's FetchContent, hence, I added the following code to my CMakeLists.txt:
include(FetchContent REQUIRED)
# INCLUDING APACHE ARROW ================================ #
message(STATUS "Searching for Apache Arrow")
FetchContent_Declare(
arrow
GIT_REPOSITORY https://github.com/apache/arrow.git
GIT_TAG apache-arrow-0.15.1
)
FetchContent_GetProperties(arrow)
if(NOT arrow_POPULATED)
message(STATUS "Populating Arrow")
FetchContent_Populate(arrow)
add_subdirectory(${arrow_SOURCE_DIR}/cpp ${arrow_BINARY_DIR})
endif()
I can find the code inside my project now - still can't use include arrow/api.h though - but whenever I try to build it I receive errors from the CMakeLists.txt of Apache Arrow cpp src directory! Here's the CMake build log that contains the error:
-- Searching for Apache Arrow
-- Populating Arrow
-- Building using CMake version: 3.15.3
-- Arrow version: 0.15.1 (full: '0.15.1')
-- Arrow SO version: 15 (full: 15.1.0)
-- clang-tidy not found
-- clang-format not found
-- infer not found
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
-- Found cpplint executable at CPPLINT_BIN-NOTFOUND
-- Compiler command: C:/MinGW/bin/g++.exe -v
-- Compiler version: Using built-in specs.
COLLECT_GCC=C:/MinGW/bin/g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/8.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-8.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-8.2.0-3' --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-isl=/mingw --enable-libgomp --disable-libvtv --enable-nls --disable-build-format-warnings
Thread model: win32
gcc version 8.2.0 (MinGW.org GCC-8.2.0-3)
-- Compiler id: GNU
Selected compiler gcc 8.2.0
-- Arrow build warning level: CHECKIN
Configured for DEBUG build (set with cmake -DCMAKE_BUILD_TYPE={release,debug,...})
-- Build Type: DEBUG
-- Using approach to find dependencies
-- AWSSDK_VERSION: 1.7.160
-- BOOST_VERSION: 1.67.0
-- BROTLI_VERSION: v1.0.7
-- BZIP2_VERSION: 1.0.8
-- CARES_VERSION: 1.15.0
-- DOUBLE_CONVERSION_VERSION: v3.1.5
-- FLATBUFFERS_VERSION: v1.11.0
-- GBENCHMARK_VERSION: v1.5.0
-- GFLAGS_VERSION: v2.2.0
-- GLOG_VERSION: v0.3.5
-- GRPC_VERSION: v1.20.0
-- GTEST_VERSION: 1.8.1
-- JEMALLOC_VERSION: 5.2.1
-- LZ4_VERSION: v1.8.3
-- MIMALLOC_VERSION: 270e765454f98e8bab9d42609b153425f749fff6
-- ORC_VERSION: 1.5.5
-- PROTOBUF_VERSION: v3.7.1
-- RAPIDJSON_VERSION: 2bbd33b33217ff4a73434ebf10cdac41e2ef5e34
-- RE2_VERSION: 2019-08-01
-- SNAPPY_VERSION: 1.1.7
-- THRIFT_VERSION: 0.12.0
-- THRIFT_MD5_CHECKSUM: 3deebbb4d1ca77dd9c9e009a1ea02183
-- URIPARSER_VERSION: 0.9.3
-- ZLIB_VERSION: 1.2.11
-- ZSTD_VERSION: v1.4.3
-- Boost include dir:
-- Boost libraries:
-- Performing Test DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY
-- Performing Test DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY - Failed
-- Building without OpenSSL support. Minimum OpenSSL version 1.0.2 required.
-- Found hdfs.h at: D:/School/Research Project/TestApacheArrow/cmake-build-debug/_deps/arrow-src/cpp/thirdparty/hadoop/include/hdfs.h
-- CMAKE_C_FLAGS: -g -O0 -Wall -Wno-conversion -Wno-sign-conversion -Wno-unused-variable -Werror
-- CMAKE_CXX_FLAGS: -Wno-noexcept-type -fdiagnostics-color=always -g -O0 -Wall -Wno-conversion -Wno-sign-conversion -Wno-unused-variable -Werror
CMake Error at cmake-build-debug/_deps/arrow-src/cpp/src/arrow/CMakeLists.txt:362 (add_dependencies):
add_dependencies called with incorrect number of arguments
CMake Error at cmake-build-debug/_deps/arrow-src/cpp/CMakeLists.txt:814 (export):
export Export set "arrow-targets" not found.
-- ---------------------------------------------------------------------
-- Arrow version: 0.15.1
--
-- Build configuration summary:
-- Generator: MinGW Makefiles
-- Build type: DEBUG
-- Source directory: D:/School/Research Project/TestApacheArrow/cmake-build-debug/_deps/arrow-src/cpp
-- Install prefix: C:/Program Files (x86)/TestApacheArrow
-- Configuring incomplete, errors occurred!
See also "/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cmake-build-debug/CMakeFiles/CMakeError.log".
Am I missing something here? is this the correct way to include Apache Arrow in an existing project? Any idea how can I fix this error?
I'm using Windows 10 but would finally want to run the project on Linux!
We don't currently support including Apache Arrow in another CMake project using add_subdirectory. You can use ExternalProject_Add, though, and it should work. It should also be possible to use CMake's built-in find_package facility to find a pre-built package.
We would like to provide well-documented and straightforward solutions for C++ developers including Apache Arrow in their CMake projects. We'd be glad to discuss further on our developer mailing list dev#arrow.apache.org
I'm trying to compile a project using my Mac (MacOsX High Sierra) and CMake version: 3.12.2
Clicking on "Generate" gives the following error:
CMake Error in CMakeLists.txt: No known features for CXX compiler "Clang" version 9.1.0.9020039.
My CMakeLists.txt is the following:
PROJECT(rightKidney_seg)
cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
INCLUDE_REGULAR_EXPRESSION("^.*$")
FIND_PACKAGE(ITK REQUIRED)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)
ADD_EXECUTABLE(rightKidney_seg rightKidney_seg.cxx)
TARGET_LINK_LIBRARIES(rightKidney_seg ${ITK_LIBRARIES})
If I do: which gcc the result is:
/usr/bin/gcc
If I do: cc --version the result is:
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Can anyone help me in understanding why I cannot generate the project?
I try to get clang 5.0.0 working for Visual Studio 2015, because I need OpenMP 3.0 features. I installed the clang compiler (not the vs2015 version which does not have any openmp support) and use cmake:
cmake_minimum_required(VERSION 2.8.10)
project(myproject)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
include_directories("include")
add_library(libFoo STATIC Foo.cpp)
install(TARGETS Foo libFoo LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
When I now try to configure a MSVC 14 2015 Win64 build with or without toolchain LLVM-vs2014 I always get an error, that OpenMP is not found:
The C compiler identification is Clang 5.0.0
The CXX compiler identification is Clang 5.0.0
Check for working C compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe
Check for working C compiler: D:/Program Files/LLVM/msbuild-bin/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: D:/Program Files/LLVM/msbuild-bin/cl.exe
Check for working CXX compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) (found version "1.0")
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) (found version "1.0")
Configuring done
The used compiler seems to be the right one (Installed clang, not the Microsoft version), it autodetects the clang-cl binary, but OpenMP fails.
I tried to manually specify the compilers with "specify native compilers" and get the same result. It even selects the clang-cl version instead of clang++.
Related Answer, which does not solve the problem:
Compiling C code with openmp using clang-cl - Recent clang has libomp.lib and libiomp5.dll included
It is really a bit tricky and the cmake autodetection doesn't seem to work very well. What helped is
OpenMP_CXX_FLAGS="-Xclang -fopenmp"
OpenMP_C_FLAGS="-Xclang -fopenmp"
And making sure that libomp.lib is in the link libraries.
-Xclang tells the clang binary, that the following options are in clang format and not in MSVC format and -fopenmp is then just the usual OpenMP flag. Setting it any other way did not work, though.
The general pattern is: -Xclang -clangFlag1 -Xclang -clangFlag2.... Namely each Clang Style flag requires its own -Xclang.
I am trying to install an external library into my C++ project using Cmake. I want the Xcode project to be produced with that library. In my terminal i run the following from the build directory:
cmake -G Xcode ..
and that gives me the following errors:
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:6 (project):
No CMAKE_CXX_COMPILER could be found.
CMake Error at CMakeLists.txt:6 (project):
No CMAKE_C_COMPILER could be found.
I am using g++ compiler:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Edit: CMakeLists.txt file
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" PROJECT_VERSION_FULL)
string(REGEX REPLACE "[\n\r]" "" PROJECT_VERSION_FULL "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+$" "\\1" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+$" "\\1" PROJECT_VERSION_MINOR "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)$" "\\1" PROJECT_VERSION_PATCH "${PROJECT_VERSION_FULL}")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
math(EXPR LIBRARY_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(LIBRARY_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(LIBRARY_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}")
set(LIBRARY_VERSION_FULL "${LIBRARY_VERSION}.${LIBRARY_VERSION_PATCH}")
option(CODE_COVERAGE "Set ON to add code coverage compile options" OFF)
option(GENERATE_DOC "Set ON to genrate doxygen API reference in build/doc directory" OFF)
# C++11 compiler Check
if(NOT CMAKE_CXX_COMPILER_VERSION) # work around for cmake versions smaller than 2.8.10
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
endif()
if(CMAKE_CXX_COMPILER MATCHES ".*clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif()
if( (CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.7) OR
(CMAKE_COMPILER_IS_CLANGXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.2))
message(FATAL_ERROR "Your C++ compiler does not support C++11. Please install g++ 4.7 (or greater) or clang 3.2 (or greater)")
else()
message(STATUS "Compiler is recent enough to support C++11.")
endif()
if( CMAKE_COMPILER_IS_GNUCXX )
append_cxx_compiler_flags("-std=c++11 -Wall -Wextra -DNDEBUG" "GCC" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-O3 -ffast-math -funroll-loops" "GCC" CMAKE_CXX_OPT_FLAGS)
if ( CODE_COVERAGE )
append_cxx_compiler_flags("-g -fprofile-arcs -ftest-coverage -lgcov" "GCC" CMAKE_CXX_FLAGS)
endif()
else()
if(MSVC)
append_cxx_compiler_flags("/EHsc" "MSVC" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("/Od" "MSVC" CMAKE_CXX_FLAGS_DEBUG)
append_cxx_compiler_flags("/Ox" "MSVC" CMAKE_CXX_FLAGS_RELEASE)
set(vars CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
foreach(var ${vars})
string(REPLACE "/MD" "-MT" ${var} "${${var}}")
endforeach(var)
add_definitions("/DMSVC_COMPILER")
else()
append_cxx_compiler_flags("-std=c++11 -DNDEBUG" "CLANG" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-stdlib=libc++" "CLANG" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-O3 -ffast-math -funroll-loops" "CLANG" CMAKE_CXX_OPT_FLAGS)
endif()
endif()
Also CMakeEdit.log:
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
EDIT:
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools, when a full regular XCode was required (happens when CLT are installed after XCode).
I have found the solution to be this:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
After this being done, when I run cmake -G Xcode .. I get other errors:
-- The CXX compiler identification is AppleClang 7.0.0.7000176
-- The C compiler identification is AppleClang 7.0.0.7000176
CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/Platform/Darwin.cmake:76 (message):
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
""
is not set to a MacOSX SDK with a recognized version. Either set
CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
empty.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:6 (project)
EDIT 2
Looks like the SDK specified by the OS is wrong.
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but the matching SDK does not exist
at:
"/Applications/DEV/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk"
Instead using SDK:
"/Applications/DEV/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk".
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:18 (include)
CMakeLists.txt:6 (project)
-- The CXX compiler identification is AppleClang 7.0.0.7000176
-- The C compiler identification is AppleClang 7.0.0.7000176
CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/Platform/Darwin.cmake:76 (message):
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
""
is not set to a MacOSX SDK with a recognized version. Either set
CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
empty.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:6 (project)
I had the same problem, but I solved it with:
sudo xcode-select --reset
Before doing the above, xcode-select -p reported the path was /Library/Developer/CommandLineTools.
After the reset, the path was /Applications/Xcode.app/Contents/Developer.
I had the same output and could solve it by agreeing to the apple license.
sudo xcodebuild -license accept
The error you have with the SDK can usually be solved by clearing the CMake build cache and adding the following to your CMakeLists.txt before project():
SET(MACOSX_DEPLOYMENT_TARGET ${DARWIN_MAJOR_SDK_VERSION}.${DARWIN_MINOR_SDK_VERSION})
SET(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
MESSAGE("Setting MACOSX_DEPLOYMENT_TARGET to '${MACOSX_DEPLOYMENT_TARGET}'.")
If you find that doesn't solve the issue then you should check the version of Xcode is current and has the SDK installed you are specifying. Generally Homebrew and Macports CMake both should have the latest stable build of Xcode installed.
↳ https://github.com/Homebrew/homebrew/issues/23074
I had the same issue and as mentioned in one of the comments it appears to be due to the fact that I installed the command-line tools first.
I solved it by opening the Xcode app, going to Preferences -> Locations, and selecting the Xcode installation from the dropdown for Command Line Tools. It was initially blank.
I solved a similar problem by
sudo xcodebuild -license
After agreeing the license, C compiler and CXX compiler can be identified.
================================
As a reference, my error message is:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/local/Cellar/cmake/3.13.3/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/MyName/pyscf/pyscf/lib/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_114dd/fast"
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:16 (project)
-- Configuring incomplete, errors occurred!
After upgrading to the latest version of CMake, it worked again.
cmake 3.25.0
AppleClang 14.0.0.14000029