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

add cmake support #34

Merged
merged 4 commits into from Feb 18, 2016
Merged

add cmake support #34

merged 4 commits into from Feb 18, 2016

Conversation

mrgreywater
Copy link
Collaborator

This adds the CMakeLists.txt that I used to compile this project with CLion on Linux and generate the project files for Visual Studio 2013 and 2015 on Windows.

To build with Visual Studio (assuming cmake (download) and glfw3 (download) are properly installed, navigate to the project root directory and execute these commands:

mkdir vs2015
cd ./vs2015
::in the following commands, change path-to-glfw to your glfw install dir
set GLFW_INCLUDE_DIRS=path-to-glfw\include 
set GLFW_LIBRARIES=path-to-glfw\lib-vc2015\glfw3.lib
cmake .. -G "Visual Studio 14 2015"

and open the generated sln project file with Visual Studio (equivalent steps for VS2013)

To build it for linux, make sure to have cmake 3.2 (ubuntu-repository) and glfw3 (how-to) installed, navigate to the project root directory in your terminal and type:

mkdir build
cd ./build
cmake .. 
make -j4

Other targets were not tested, but should work aswell.

If this PR is merged, I would suggest to add cmake to Travis aswell, since otherwise it may happen quickly that someone edits the gyp or cmake configuration alone without checking the other configuration.

Additionally, in a follow-up PR, we could add a github submodule link to https://github.com/glfw/glfw, and compile against the local glfw source (e.g like this project), which would make it alot easier to get the project working initally. That way the manual compilation of glfw3 on linux, or setting up environment variables on windows would not be required.

@mrgreywater
Copy link
Collaborator Author

ref #21

@jfirebaugh
Copy link
Contributor

We'll want to switch over to cmake entirely if we go this route, not maintain two build systems in parallel.

cc @kkaefer

@mrgreywater
Copy link
Collaborator Author

said follow-up PR with glfw as submodule can be found here: mrgreywater@d658b8b

usage would be:

git submodule init
git submodule update
mkdir build
cd ./build
cmake .. 
make -j4

and it would remove the requirement to install glfw manually.

edit: added it to this PR instead.

@mourner
Copy link
Member

mourner commented Feb 16, 2016

Great! @mrgreywater yeah, let's remove the old build system fully in favor of CMake.

@mourner
Copy link
Member

mourner commented Feb 16, 2016

@mrgreywater BTW, just added you as the repo collaborator. Thank you for all the awesome contributions! Now you can make branches in the upstream repo (and manage issues), but be sure to still submit PRs for any significant changes.

@mrgreywater
Copy link
Collaborator Author

@mourner wow, thanks.
However I would prefer if someone else could merge this PR and do the appropriate changes to travis. I am also not quite sure which files can be removed related to gyp.
I guess it's the makefile, the .mason submodule, the dep folder, configure, and all the .gypi and .gyp files.

@kkaefer
Copy link
Contributor

kkaefer commented Feb 17, 2016

Just a heads up that using CMake 3 on Travis requires adding these sources/packages:

addons:
  apt:
    sources: [ 'george-edison55-precise-backports' ]
    packages: [ 'cmake', 'cmake-data' ]

# optional: -march=native (builds with the optimizations available on the build machine (only for local use!))
endif()
else()
message(WARNING "Building earcut with unknown compiler.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is triggered when compiling with Clang. It means that Clang won't receive any compiler flags.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed
edit: I just noticed I still need to enable optimization for the C-Compiler (not just C++).

@kkaefer
Copy link
Contributor

kkaefer commented Feb 17, 2016

As part of this PR, we should also completely remove the existing build system, as we won't be maintaining two systems side-by-side.

@mourner
Copy link
Member

mourner commented Feb 17, 2016

@kkaefer want to take a stab at this? See #34 (comment)

@mrgreywater
Copy link
Collaborator Author

@kkaefer I gave you access to https://github.com/mrgreywater/earcut.hpp/tree/cmake in case you want to push commits to this PR yourself. Or else I may try to remove gyp and make the changes to travis later myself, even though I cannot tell how difficult it will get, as I haven't configured any gyp/travis systems yet.

@mrgreywater
Copy link
Collaborator Author

@kkaefer @jfirebaugh @mourner looks like it works now. Would be nice if one of you could check if I haven't missed anything/ deleted too much related to gyp.

@mourner
Copy link
Member

mourner commented Feb 17, 2016

Oh wow! Isn't this just lovely?
image

mourner added a commit that referenced this pull request Feb 18, 2016
@mourner mourner merged commit eaba8d1 into mapbox:master Feb 18, 2016
@kkaefer kkaefer deleted the cmake branch February 18, 2016 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants