Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Best practices using CMake  (Read 7351 times)

0 Members and 1 Guest are viewing this topic.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« on: October 17, 2010, 09:52:43 pm »
I used now CMake for a while, and I wonder where should I build the SFML binaries so its temporary folders and projects doesn't disturb the main SFML folder.

I am currently bulding the binaries in SFML2/projects/vc2010-debug, SFML2/projects/vc2010-release.

What is your chosen binary folder?

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Best practices using CMake
« Reply #1 on: October 21, 2010, 02:01:32 am »
Your standard CMake procedure should be:
cd sfml2
mkdir build
cd build
cmake ..
make

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« Reply #2 on: October 21, 2010, 10:55:59 am »
Quote from: "Svenstaro"
Your standard CMake procedure should be:
cd sfml2
mkdir build
cd build
cmake ..
make

That's on Linux, right? What about Windows?

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Best practices using CMake
« Reply #3 on: October 21, 2010, 11:46:02 am »
It works the same on all supported platforms. On Windows, assuming your cmake.exe is on PATH, you can use exactly my commands below.

However, since you are probably not going to use MinGW, you will not have make. Due to that, you need to use cmake -G "Visual Studio 10" instead and open the generated project files with your IDE afterwards.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Best practices using CMake
« Reply #4 on: October 21, 2010, 11:52:45 am »
With CMake, I personnally find it useless to generate solutions/workspaces. Command line compilation is so easier, once you've properly configured the project. On Windows you can choose to generate mingw32 makefiles (gcc) or nmake makefiles (VC++).

Quote
What is your chosen binary folder?

I think it doesn't matter, as long as it's not the source directory itself.
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« Reply #5 on: October 21, 2010, 12:41:49 pm »
Quote from: "Svenstaro"
It works the same on all supported platforms. On Windows, assuming your cmake.exe is on PATH, you can use exactly my commands below.

However, since you are probably not going to use MinGW, you will not have make. Due to that, you need to use cmake -G "Visual Studio 10" instead and open the generated project files with your IDE afterwards.

Oh, I was using the CMake gui. I will try what you say to work with Visual studio!

Quote from: "Laurent"
With CMake, I personnally find it useless to generate solutions/workspaces. Command line compilation is so easier, once you've properly configured the project. On Windows you can choose to generate mingw32 makefiles (gcc) or nmake makefiles (VC++).

Didn't even know about nmake! (Well I think I used it once to compile Qt). I will try to use it.

Thanks for all the replies. I understand CMake better now.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Best practices using CMake
« Reply #6 on: October 21, 2010, 12:45:23 pm »
Quote
Oh, I was using the CMake gui. I will try what you say to work with Visual studio!

cmake-gui is just a graphical front-end to cmake, you can do the same things with both. I would recommend to stick to cmake-gui if you're not very familiar with cmake and the various project's options.

I should really finish this CMake/SFML tutorial :oops:
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« Reply #7 on: October 21, 2010, 12:55:00 pm »
Quote from: "Laurent"
Quote
Oh, I was using the CMake gui. I will try what you say to work with Visual studio!

cmake-gui is just a graphical front-end to cmake, you can do the same things with both. I would recommend to stick to cmake-gui if you're not very familiar with cmake and the various project's options.

I should really finish this CMake/SFML tutorial :oops:

Oh no, I really want to get used to the Windows console.

Right now I did this (using the command help):
Quote
cd SFML2/cmake-build
cmake -g "NMake Makefiles" ..
nmake

Now I have the shared release libraries at SFML/cmake-build/lib.
What about getting the debug ones?[/quote]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Best practices using CMake
« Reply #8 on: October 21, 2010, 02:06:27 pm »
I think there's no point using the command line interface. This time you're asking for debug mode, but then you'll block at each new option. With the graphical interface, you immediately see what's available, and what options you need to fill or change. I personally never use the command line interface on Windows, and I use the interactive one (cmake -i) on Linux.

Here is a useful link:
http://www.cmake.org/Wiki/CMake_Useful_Variables
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« Reply #9 on: October 21, 2010, 05:25:38 pm »
Quote from: "Laurent"
I think there's no point using the command line interface. This time you're asking for debug mode, but then you'll block at each new option. With the graphical interface, you immediately see what's available, and what options you need to fill or change. I personally never use the command line interface on Windows, and I use the interactive one (cmake -i) on Linux.

Here is a useful link:
http://www.cmake.org/Wiki/CMake_Useful_Variables

I see your point. Then, must I change CMAKE_BUILD_TYPE to DEBUG  if I want to compile SFML2 debug libraries? I ask this because both solutions have the debug and release flags in the project.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Best practices using CMake
« Reply #10 on: October 21, 2010, 05:29:54 pm »
If you generate a workspace/solution that supports multiple configurations, you will have all of them and CMAKE_BUILD_TYPE will be ignored. Otherwise, like for makefiles, CMAKE_BUILD_TYPE defines the build type.
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Best practices using CMake
« Reply #11 on: October 21, 2010, 08:03:07 pm »
Quote from: "Laurent"
If you generate a workspace/solution that supports multiple configurations, you will have all of them and CMAKE_BUILD_TYPE will be ignored. Otherwise, like for makefiles, CMAKE_BUILD_TYPE defines the build type.

Nice, thanks.