Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to get cmake to output an Xcode project file? #382

Open
JohnCoates opened this issue Nov 27, 2016 · 13 comments
Open

Any way to get cmake to output an Xcode project file? #382

JohnCoates opened this issue Nov 27, 2016 · 13 comments

Comments

@JohnCoates
Copy link

JohnCoates commented Nov 27, 2016

I'm trying to make a new rule, but it would be useful if I could work within Xcode.

I get the following error when running cmake -G Xcode

CMake Error at /Users/macbook/Dev/Clones/oclint/oclint-core/cmake/OCLintConfig.cmake:56 (FIND_PACKAGE):
  Could not find a package configuration file provided by "LLVM" with any of
  the following names:

    LLVMConfig.cmake
    llvm-config.cmake

  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
  "LLVM_DIR" to a directory containing one of the above files.  If "LLVM"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:9 (INCLUDE)

I've tried changing the LLVM_DIR in the produced CMakeCache.txt but that doesn't work either. Just wondering if there's a recommended way to do this?

@ryuichis
Copy link
Contributor

ryuichis commented Dec 1, 2016

@ryuichis ryuichis closed this as completed Dec 1, 2016
@JohnCoates
Copy link
Author

Which part of that @ryuichis? I can build it fine with the instructions on that page. However, when specifically trying to output an Xcode project with CMake, the command fails. I don't see anything on that page regarding this.

@ryuichis ryuichis reopened this Dec 4, 2016
@ryuichis
Copy link
Contributor

ryuichis commented Dec 4, 2016

@JohnCoates hey, sorry, I didn't catch your point earlier.

Frankly speaking, I am not aware of people who work on oclint project entirely inside Xcode. I know people who just use it as a syntax highlighter but not fully depend on it.

Maybe you can work with me and try to understand if using Xcode is doable.

Back to the initial question: could you try to call the following commands inside oclint-scripts folder

./clang co
./countly co
./googleTest co

before running cmake -G Xcode?

I am not sure if it will work, but at least, a good starting point.

I pointed the link to the document earlier, because if you give up Xcode and want to work on your new rules by using your favorite text editor, that link should have the info you need for setting things up, and the scaffolding script to ease some of the rule generations.

@JohnCoates
Copy link
Author

Thanks for working with me on this. Below is the result I got, and unfortunately I got the same error as above when running cmake -G Xcode

Macbook:oclint-scripts macbook$ ./clang co
Clang folder exists!
Macbook:oclint-scripts macbook$ ./countly co
./googleTest co
Countly folder exists!
Macbook:oclint-scripts macbook$ ./googleTest co
Cloning into 'googletest'...
remote: Counting objects: 7422, done.
remote: Total 7422 (delta 0), reused 0 (delta 0), pack-reused 7422
Receiving objects: 100% (7422/7422), 2.49 MiB | 2.45 MiB/s, done.
Resolving deltas: 100% (5513/5513), done.

Unfortunately I'm not familiar with CMake scripts, so I don't know how to point it to the right direction to look for the LLVM cmake files. I'll try and look into this.

@ryuichi-assistant
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment.

@ryuichi-assistant
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

@Dis3buted
Copy link

cmake -G "Xcode" ../llvm-4.0.1.src works for me

@JohnCoates
Copy link
Author

@Dis3buted

Running that only built an Xcode project for llvm, and I didn't see any OCLint targets. For reference here all the commands I ran:

git clone https://github.com/oclint/oclint
cd oclint
svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_401/final/ llvm-4.0.1.src
mkdir buildXcode
cd buildXcode
cmake -G "Xcode" ../llvm-4.0.1.src

@JohnCoates
Copy link
Author

JohnCoates commented Aug 21, 2017

Figured it out! Here are the commands I ran to get oclint-rules compiling in Xcode.
After running all of these commands you need to open the Xcode projects for oclint-core and oclint-metrics and compile those before oclint-rules will compile.

export SOURCE_ROOT=/path/to/oclint
export BUILD_ROOT=$SOURCE_ROOT/buildXcode

git clone https://github.com/oclint/oclint $SOURCE_ROOT

# download LLVM/clang code
svn co --quiet http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_500/rc2 $SOURCE_ROOT/llvm
svn co --quiet http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_500/rc2 $SOURCE_ROOT/llvm/tools/clang
svn co --quiet http://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_500/rc2 $SOURCE_ROOT/llvm/projects/compiler-rt

# Compile LLVM/clang

mkdir -p $BUILD_ROOT/llvm
cd $BUILD_ROOT/llvm
cmake -D CMAKE_BUILD_TYPE=Release -D LLVM_BUILD_RUNTIME=ON -D CMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -D CMAKE_INSTALL_PREFIX=$BUILD_ROOT/llvm-install $SOURCE_ROOT/llvm
make -j 8
make install

# Compile oclint-core

mkdir -p $BUILD_ROOT/oclint-core
cd $BUILD_ROOT/oclint-core
cmake -G Xcode -D OCLINT_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=$BUILD_ROOT/llvm-install/bin/clang++ -D CMAKE_C_COMPILER=$BUILD_ROOT/llvm-install/bin/clang -D LLVM_ROOT=$BUILD_ROOT/llvm-install $SOURCE_ROOT/oclint-core

# Compile oclint-metrics

mkdir -p $BUILD_ROOT/oclint-metrics
cd $BUILD_ROOT/oclint-metrics
cmake -G Xcode -D OCLINT_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=$BUILD_ROOT/llvm-install/bin/clang++ -D CMAKE_C_COMPILER=$BUILD_ROOT/llvm-install/bin/clang -D LLVM_ROOT=$BUILD_ROOT/llvm-install $SOURCE_ROOT/oclint-metrics

# Compile oclint-rules

mkdir -p $BUILD_ROOT/oclint-rules
cd $BUILD_ROOT/oclint-rules
cmake -G Xcode -D OCLINT_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=$BUILD_ROOT/llvm-install/bin/clang++ -D CMAKE_C_COMPILER=$BUILD_ROOT/llvm-install/bin/clang -D OCLINT_BUILD_DIR=$BUILD_ROOT/oclint-core -D OCLINT_SOURCE_DIR=$SOURCE_ROOT/oclint-core -D OCLINT_METRICS_SOURCE_DIR=$SOURCE_ROOT/oclint-metrics -D OCLINT_METRICS_BUILD_DIR=$BUILD_ROOT/oclint-metrics -D LLVM_ROOT=$BUILD_ROOT/llvm-install $SOURCE_ROOT/oclint-rules

@ryuichis
Copy link
Contributor

@JohnCoates thanks for providing this detailed instructions, do you want to add this to https://github.com/oclint/oclint-docs, so that others can get benefits from your effort as well?

And by the way, your first two steps can be simplified to ./clang co and ./clang build. The clang script is inside oclint-scripts folder.

Moreover, if you don't want to build LLVM/clang locally, instead, you rather use a prebuilt binary, then you can call ./clang prebuilt. It will download the archive, and untar it for you.

@JohnCoates
Copy link
Author

Thanks for the suggestions @ryuichis. I've attached a rst document
with the instructions, how does it look?
xcodeDevelopmentEnvironment.txt

@ryuichis
Copy link
Contributor

ryuichis commented Sep 1, 2017

Nice, by looking at this, I started to think it will be better to add a script to oclint-scripts folder that automates the entire thing. And then, your document could be simplified to just call that script. What do you think?

@ryuichis ryuichis reopened this Sep 1, 2017
@JohnCoates
Copy link
Author

Yeah that sounds like a simpler solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants