PROJECT instruction MUST BE the first one after CMAKE_MINIMUM_REQUIRED:
-- lib
CMakeLists.txt
{
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.8)
PROJECT(lib)
ADD_SUBDIRECTORY(libtest)
}
From: CMake on behalf of Emmanuel HOUITTE
Date: Friday 11 September 2015 15:26
To: "[email protected]<mailto:[email protected]>"
Subject: [CMake] CMAKE_CXX_COMPILE_OBJECT not set with ADD_SUBDIRECTORY
I’m working with cmake version 2.8.12.2 on CentOS6.
I’ve got a very simple project with one subdirectory.
Each directory has a CMakeLists.txt file.
The ADD_SUBDIRECTORY seems to remove the default generated CMAKE rule variables
in the generation step.
Is it normal? How to get an example without generation errors?
If I replace the ADD_SUBDIRECTORY by the code of the second CMakeLists.txt,
there is no problem.
This is the content of my project:
-- lib
CMakeLists.txt
{
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.8)
ADD_SUBDIRECTORY(libtest)
PROJECT(lib)
}
-- libtest
CMakeLists.txt
{
FILE(WRITE "empty.cpp" "")
ADD_LIBRARY(test STATIC empty.cpp )
}
And the results:
$ cmake -DCMAKE_BUILD_TYPE=Release
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may be not
be built correctly.
Missing variable is:
CMAKE_CXX_COMPILE_OBJECT
CMake Error: Error required internal CMake variable not set, cmake may be not
be built correctly.
Missing variable is:
CMAKE_CXX_CREATE_STATIC_LIBRARY
-- Generating done
-- Build files have been written to: /home/test/lib
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake