This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Need usable documentation for CMakeLists.txt

Tags: None
(comma "," separated)
Snurg
Registered Member
Posts
1
Karma
0
I am trying out KDevelop (4.7) today for the first time.

However, there are problems.

The thing is that I have a project consisting of a few C files and a makefile.
Compiling works fine using my makefile using normal make (when not using KDevelop).
Now I was just thinking about trying out KDevelop by using its debugger first.

The main problem is am unable to find any usable info on the CMakeLists.txt format and options.
I seem to need that to get cmake compile and link the modules with KDevelop.
Even on the cmake.org website and the documentation there, the information is badly structured and poor at best.
Can you point me to a complete documentation on CMakeLists.txt, that includes how to use the files directive, please?

After wasting two hours searching the internet, the only way I found to get KDevelop to compile my modules was using globs, like described here: viewtopic.php?f=218&t=150502
But, it still does not link.

Alternatively, It would be great, if there is a non-hackish way to ditch cmake and just use normal make instead with KDevelop :)
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Hi,

please consider using KDevelop 5.2.1 from https://www.kdevelop.org/download, 4.7 is years old.

For a project like this, it should not at all be difficult to write a CMakeLists.txt. All you need is something like

Code: Select all
project(foo)
cmake_minimum_required(VERSION 3.0)

add_executable(myprogram
  source1.cpp
  source2.cpp
  source3.cpp
)

# for each dependency, something like
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
target_link_libraries(myprogram Qt5::Core Qt5::Gui Qt5::Widgets)

install(TARGETS myprogram DESTINATION bin)


The official cmake documentation is not so bad, just read the pages for add_executable, find_package, target_link_libraries and maybe include_directories. Useful are also configure_file and the CMAKE_CXX_FLAGS etc variables.


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]