Reputation: 3356
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
project(WINDOW CXX)
set(WINDOW_SRCS window.cpp)
add_executable(Window ${WINDOW_SRCS})
set(CMAKE_CXX_STANDARD 14)
find_library(OPENGL_LIB
NAMES lGLEW lglfw3 lGL lrt lm ldl lXrandr lXinerama lXxf86vm lXext lXcursor lXrender lXfixes lX11 lpthread lxcb lXau lXdmcp lXi lSOIL lassimp
PATHS /usr/lib /usr/local/lib
)
if(OPENGL_LIB)
target_link_library(Window ${OPENGL_LIB})
endif()
I am trying to write a CMakeList.txt file. I get an error in the generated Makefile
makefile:1: *** missing separator. Stop.
I've added tabs
in the beginning of each line. I can't figure out where is wrong
Upvotes: 1
Views: 1467
Reputation: 4609
The problem is that you haven't cleaned CMake generated files from the previous CMake configuration run.
Please remove the CMakeCache.txt
file and Makefile
and the directory CMakeFiles
and if they exists the files cmake_install.cmake
and CTestTestfile.cmake
.
Now you can rerun the CMake configuration via cmake .
again.
Then execute make
and it should be ok.
In the answer I haven't attempted to improve your CMakeLists.txt
, but just to make the issue you are encountering to go away.
Otherwise, as suggested by @roalz, you could use the find_package()
to find OpenGL.
Another "improvement" could be to use out-of-source builds. In this way all the build results will be contained in one directory with no interference with the source tree. In this case, to start from a clean state and rerun the CMake configuration, you will only need to remove that build directory, and not all the single files created around. This is particularly useful for projects that have nested source directories (more than one level).
Upvotes: 1