I am totally new in cmake so excuse me if asking this low question but cannot find the answer on google.
I'm trying to create an empty project on top of Ogre3d SDK. I built an ogre3d source with cmake and vs2015, now I want to create my project on top of ogre libs and headers. so as explained here I create a cmakelists.txt file and add these lines to it :
# specify which version you need
find_package(OGRE 1.10 REQUIRED)
project(OG1)
# the search paths
include_directories(${OGRE_INCLUDE_DIRS})
link_directories(${OGRE_LIBRARY_DIRS})
# copy essential config files next to our binary where OGRE autodiscovers them
file(COPY ${OGRE_CONFIG_DIR}/plugins.cfg ${OGRE_CONFIG_DIR}/resources.cfg
DESTINATION ${CMAKE_BINARY_DIR})
everything is ok and success on creating cmake files and generate .sln with cmake-gui but I hope cmake creates an empty project with the name OG1 then I can run my first ogre helloword but it generates a .sln file that only contains just ALL_BUILD and ZERO_CHECK. How can I create a clean project that has all configuration and is ready for just using ogre classes (i mean it automatically configure link, includes, etc)?
The CMake terminology is slightly different from Visual Studio's.
In particular, each CMake
project
will create a Visual Studio solution (.sln
file), while all of the CMake targets belonging to that CMake project will appear as Visual Studio projects within the corresponding solution.So your project is clearly missing a target. In your case, you probably want an executable target, which is added using
add_executable
. The executable can have the same name as the project. Note that an executable cannot be completely empty in CMake. While the concept of an empty executable project exists in Visual Studio, it is not valid in other build systems, so CMake cannot not support it either. So you need to specify at least one source file here:With that in place, you can also attach the remaining build options to the target instead. This step is optional, as your code would have also worked here, but is considered good style in modern CMake:
Note that in CMake, we prefer to not use the library directory for telling the build system of the library's location, but instead always use the full path to the library file.