CMake Error: Could not create named generator XCode - xcode

i have checked out llvm/clang/compiler-rt sources from official git repositories, but i'm having:
MBA-Anton:llvm_34_xcode_build asmirnov$ cmake -G XCode ../llvm_34
CMake Error: Could not create named generator XCode
LLVM sources:
MBA-Anton:llvm_34_xcode_build asmirnov$ ls ../llvm_34
CMakeLists.txt Makefile.common cmake llvm.spec.in
CODE_OWNERS.TXT Makefile.config.in configure projects
CREDITS.TXT Makefile.rules docs test
LICENSE.TXT README.txt examples tools
LLVMBuild.txt autoconf include unittests
Makefile bindings lib utils
Cmake version:
MBA-Anton:llvm_34_xcode_build asmirnov$ cmake -version
cmake version 2.8.11.1
Xcode generator should be supported for this cmake version according to doc and output:
MBA-Anton:llvm_34_xcode_build asmirnov$ cmake --help
...
Generators
The following generators are available on this platform:
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files (experimental).
Xcode = Generate Xcode project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
= Generates Eclipse CDT 4.0 project files.
KDevelop3 = Generates KDevelop 3 project files.
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.

I've never used CMake, but from what I've seen from your question it's just a question of case-sensitivity.
The generator is called Xcode and not XCode.

I also met this problem, it was resolved after I renamed Xcode-beta to Xcode

Related

Why OpenCV 4.5.2 doesn't have apps built

I installed OpenCV 4.5.2 using the Windows installer and when I looked in the apps folder, I couldn't find some apps (create_samples, train_cascade). So, I downloaded the code and I generated visual studio projects using CMake. After I built all those project, again, in the app folder there were no project files to build those apps.
I also run cmake . in an app directory, but this error came out:
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.
CMake Error at CMakeLists.txt:4 (ocv_add_application):
Unknown CMake command "ocv_add_application".
-- Configuring incomplete, errors occurred!
See also "C:/opencv/opencv-master/apps/createsamples/CMakeFiles/CMakeOutput.log".
this is the CMakeLists.txt file that I run:
file(GLOB SRCS *.cpp)
ocv_add_application(opencv_createsamples
MODULES opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d opencv_videoio
SRCS ${SRCS})
In all honesty, last time that I used CMake was 10 years ago and I really would like an hand to figure this out.
Thanks
STACK:
CMake 3.20.3
OpenCV 4.5.2
Python 3.9.5
Visual Studio 16.10.0
Wndows 10
I found out why this is happening. In opencv 4.5 (I didn't check other versions), the line in the cmake file that generate the solution for traincascade and createsamples, are explicitly commented out. This because building those apps will generate more than 600 errors! Let's hope this problem will be fixed soon.
from https://github.com/opencv/opencv/issues/13231
These apps has been disabled during legacy C API removal. Rewriting them
with C++ API was not an option because it is too easy to break them
and hard to test.
Also modern approaches via DNN provides much better results - just
compare OpenCV face detector with CascadeClassifier and DNN.

CMake OSX build finds different SDK with makefiles generator and Xcode generator

I am working on a cross platform project that uses cmake.
On Mac OS, most of my colleagues use Xcode, but I prefer Clion (which uses the makefile generator). After a recent commit, I started getting build errors:
<name>.h:26:8: error: unknown type name 'NSErrorDomain'
Those errors aren't there in the Xcode version of the project. Upon further investigation, it appears that the Unix Makefiles generated project used by Clion is pulling in a different version of the SDK and of NSError.h. The version included in the makefile project does not include a definition of NSErrorDomain.
With the following snippet added to my main CMakelists.txt :
find_library(AUDIO_UNIT AudioUnit)
message ( STATUS "AUDIO_UNIT = ${AUDIO_UNIT}" )
find_path ( NSERROR "NSError.h" )
message ( STATUS "NSERROR = ${NSERROR}")
cmake -G "Unix Makefiles" ../
-- AUDIO_UNIT = /System/Library/Frameworks/AudioUnit.framework
-- NSERROR = /System/Library/Frameworks/Foundation.framework/Headers
cmake -G "Xcode" ../
-- AUDIO_UNIT = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AudioUnit.framework
-- NSERROR = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Foundation.framework/Headers
So the Xcode generator project seems to know to use the SDK in the Xcode App bundle, but makefiles is just pulling from /System/Library.
I have tried setting CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET, but they seem to have no effect.
Is there a way that I can tell the makefile generator to pull from the Xcode App bundle?

C++: setting DebugInformationFormat using Clang and VS14

I'm trying to build a simple hello-world program using cmake, clang and VS14 with Clang 3.7.
cmake ../src -G "Visual Studio 14 2015" -T "v140_clang_3_7"
My CMakeLists.txt looks as follows:
cmake_minimum_required(VERSION 2.8.9)
project (test)
add_executable(test testfile.cpp)
I get the error that DebugInformationFormat has an incorrect value:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Clang
.targets(206,5): error : Element <DebugInformationFormat> has an value of
"ProgramDatabase". [...\build\CMakeFiles\CMakeTmp\cmTC_c45da.vcxproj]
I did some research and tried to override the default value in my CMakeLists.txt without success
set (CMAKE_CXX_FLAGS "-g2 -gdwarf-2")
Whatever I tried so far, didn't work out (of course I cleaned the build directory before every new cmake)
I got the same problem on build project with CMake, VS15, Clang 3.7.
I just got an LLVM snapshotbuild for windows form http://llvm.org/builds/
Install a recent version of clang (at the time of writing v3.9.0).
After the installation Properties -> General -> Platform Tools -> LLVM-vs2014 (Switch to LLVM-vs2014), and build.

How to generate .lib files with mingw toolchain?

I have installed MingW GCC 4.8.1 in my system. I am trying to build the LLVM source code( with some extra modification). Cmake 2.8.12 is used to generate the makefiles and visual studio solution files. I am able to build the LLVM source (Rel 3.4.2) with Visual Studio 2010 And is generating both lib and dll file. But with MingW I am not able generate .lib files by simply running Make all.
How to make MingW generate .lib file while building the project ?
Use CMAKE_GNUtoMS. Add -DCMAKE_GNUtoMS=ON to the build command. See this CMake issue. As result, a .lib file will be generated along with the .dll.a file.

OpenCV - file was built for unsupported file format which is not the architecture being linked (i386)

I followed this tutorial : http://tilomitra.com/opencv-on-mac-osx/ to compile OpenCV for Mac OSX in order to use it in XCode 3.2.3
I had no error when compiling openCV. But in XCode I get file was built for unsupported file format which is not the architecture being linked (i386) for each dylib and Symbols not found after.
Any clue ?
steps to compile and run c++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1
Having the right tools
download opencv-unix from http://sourceforge.net/projects/opencvlibrary/files/ and untar it wherever
download cmake .dmg from http://www.cmake.org/cmake/resources/software.html and install it
i am assuming you have xcode 4.6 on os x lion which includes the ios sdk 6.1
go to xcode preferences to download and install the Command Line Tools so you have g++ etc.
Use cmake to compile opencv
go to the extracted opencv folder
create a build directory
mkdir build
cd build
cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" ..
make -j8
sudo make install
from the build folder, go to bin/ and run one of the tests
./opencv_test_stitching
Create your own c++ opencv xcode project
fire up xcode and create a new xcode project
select Command Line Tool for the type of project under os x
open your project's build settings
under Architectures, set Architecture to 64-bit intel. also set Valid Architectures to x86_64
under Build Options, set Compiler for C/C++ to Default Compiler
under Search Paths, set Header Search Paths to /usr/local/include
also under Search Paths, set Library Search Paths to /usr/local/lib
under Apple LLVM compiler 4.2 - Language set C++ Standard Library to libstd++
Add the compiled opencv libraries to your project
go to the Build Phases tab next to Build Settings tab you were in
inside Link Binary With Libraries, click on the + sign and choose Add Other
hit the front slash / on your keyboard and enter /usr/local/lib
hit enter and select the libraries you want to use in your project
make sure you always select libopencv_core.2.4.4.dylib
hit enter and you will see the selected dylibs under your project
write some code
first lets organize the files, right click on your project blueprint icon and select New Group
name the new group opencv or whatever
drag the dylibs and drop them in that group
open main.cpp
copy code from any of the sample tests that came with opencv and paste it here
make sure all the required dylibs are added, for example, if you copied the opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps
libopencv_core.2.4.4.dylib
libopencv_highgui.2.4.4.dylib
libopencv_stitching.2.4.4.dylib
Cheers.

Resources