0

I used qmake but I'd like to experiment with cmake..

I would like to work with a project structure like the following:

Myproject
  -- build
    -- release
    -- debug
  -- src
    -- mysource1.cpp
    -- mysource1.h
    -- mysource2.cpp
    -- mysource2.h
    ...
    -- main.cpp
  myexecutable_release
  myexecutable_debug
  CMakeLists.txt

How do I set CMakeLists.txt to use the above structure ? How do I associate debug and release configuration using QtCreator ? Or, as I don't have any particular complex need, should I just forget it and continue using qmake ? (it's a scientific software for linux/windows)

BDW: yes, I have read the CMake tutorial, but instead of starting from basic things like this question they already introduce complex topics like introspection and generators.. maybe different audience ??

Antonello
  • 6,092
  • 3
  • 31
  • 56
  • 2
    In my opininion, if you have been using qtcreator and you are used to qmake projects, you shouldn't change to cmake unless it's necessary. qmake can get you what you want. If you still have to move to cmake, there is plenty of tutorials out there, some of them covering the basics you are looking for. – Яois May 21 '14 at 08:33

1 Answers1

0
project (Myproject) 
set(sources src/mysource1.cpp 
            src/mysource2.cpp 
            src/mysource1.h 
            src/mysource2.h 
            src/main.cpp
   )
add_executable(myexecutable ${sources})

In the folder build run

cmake ..

and build. For gcc debug builds, see this answer. For additional options (e.g. different generators) consult cmake documentation.

Community
  • 1
  • 1
Peter Petrik
  • 9,701
  • 5
  • 41
  • 65