Hello everyone,
I am working on converting my project from using a handwritten
Makefile to using cmake.
I have been playing with cmake but I keep running into problems and
I'm probably writing really ugly CMakeLists.txt files.
My project is laid out like this:
graphics/
data/
bark.rgb
ground.rgb
leaf.rgb
library/
Affine.cpp
Affine.h
Camera.cpp
Camera.h
Canvas.cpp
Canvas.h
Color.cpp
Color.h
Light.cpp
Light.h
Material.cpp
Material.h
Matrix.cpp
Matrix.h
Quaternion.cpp
Quaternion.h
Ray.cpp
Ray.h
Texture.cpp
Texture.h
utility.cpp
Vertex.cpp
Vertex.h
programs/
exam.cpp
forces.cpp
ifs.cpp
lsystem.cpp
raytrace.cpp
subdivide.cpp
testray.cpp
My "library" is all the classes that I use while the programs are each
files with a main function in them.
My code relies on Glut and OpenGl.
I would like cmake to build an executable for each of the files in
programs and preferably build out of source so things stay relatively
clean.
Here is what my CMakeLists.txt files currently look like and I have no
idea if I'm remotely doing the right thing.
In the root directory /
cmake_minimum_required (VERSION 2.6)
project(Pemberton)
find_package(GLUT)
find_package(OpenGL)
add_definitions(-Wall -Wextra -pedantic -Werror -O3)
SUBDIRS(library programs)
INCLUDE_DIRECTORIES(library)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/library")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
In library/
FILE(GLOB SOURCE_FILES *.cpp)
FILE(GLOB INCLUDE_FILES *.h)
SOURCE_GROUP("Source Files" FILES ${SOURCE_FILES})
SOURCE_GROUP("Header Files" FILES ${HEADER_FILES})
ADD_LIBRARY (Graphics STATIC ${SOURCE_FILES} ${INCLUDE_FILES})
In programs/
include_directories(../library)
#FILE(GLOB SOURCE_FILES .*.cpp)
#FILE(GLOB INCLUDE_FILES *.h)
#SOURCE_GROUP("Source Files" FILES ${SOURCE_FILES})
#SOURCE_GROUP("Header Files" FILES ${HEADER_FILES})
find_package(GLUT)
find_package(OpenGL)
add_executable(lsystem lsystem.cpp ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
#set(PROGRAMS ifs lsystem raytrace subdivide)
#set(CORELIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} GL GLU)
#foreach(programs ${PROGRAMS})
# add_executable(${program} ${SOURCE_FILES} ${INCLUDE_FILES})
#target_link_libraries(${program} ${CORELIBS})
#endforeach(program)
What is the correct way to set this up? Currently it's saying it can't
find OpenGL functions. I would like to have some really nice clean
cmake files.
Best regards,
Craig
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake