Home > Back-end >  Have any bosses have been familiar with cmake. Help to look at. This is a bug cmake?
Have any bosses have been familiar with cmake. Help to look at. This is a bug cmake?

Time:10-12

I wrote a simple Qt application, use qmake and pro, with the administration of cmake
Source files in the directory:/home/username/QtProjects/untitled
There is only one file. The main CPP, content as follows:
 
#include
#include

using namespace std;

Int main (int arg c, char * * argv)
{
QApplication app (arg c, argv);
QWidget * w=new QWidget ();
W - & gt; Show ();
Return the app. The exec ();
}

CMakeLists. TXT content is as follows:
 
Cmake_minimum_required (VERSION 2.8)

Set (CMAKE_CXX_STANDARD 11)
Set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
Set (CMAKE_BUILD_TYPE "Debug")

Set (CMAKE_PREFIX_PATH/home/username/qt/5.7/gcc_64/bin)
Set (CMAKE_INCLUDE_CURRENT_DIR ON)

Qt MOC # open
Set (CMAKE_AUTOMOC ON)
# open Qt ROC
Set (CMAKE_AUTORCC ON)
# open Qt UIC
Set (CMAKE_AUTOUIC ON)
# Qt module
Set (QT Core Gui Widgets)
# project name
Project (untitled)
# qt installation root directory
Set (QT_BASE_DIR/home/username/qt/5.7/gcc_64)
# header file search directory
Include_directories (
The ${QT_BASE_DIR}/include/QtCore
The ${QT_BASE_DIR}/include/QtGui
The ${QT_BASE_DIR}/include/QtWidgets
The ${QT_BASE_DIR}/include
)
# libraries directory
Link_directories (
The ${QT_BASE_DIR}/lib
)
# add an executable program
Add_executable (${PROJECT_NAME} ". The main CPP ")
# specified link library
Target_link_libraries (
The ${PROJECT_NAME}
Qt5Core
Qt5Gui
Qt5Widgets
)


The problem on the -fpic, I perform cmake command: the compilation of the program directory
 cmake/home/username/QtProjects/untitled 

Executed directly make compilation, complains:


Error that no use -fpic here, but my CMakeLists. TXT clearly is garnering -fpic, oddly, if at this time, to do the same again cmake command:
 cmake/home/username/QtProjects/untitled 
, compile again, there is no problem, compared before and after the differences I found the first execution cmake, in:/CMakeFiles/untitled. Dir/flags. The make file CXX_FLAGS did not take the -fpic, however the second after execution, here with the -fpic, surprised the same command twice appeared different results,

My machine is Ubuntu 16.04, apt - get install cmake version is 3.5.1 track of.
Later I manually compile installed cmake 3.16.5 did not appear this problem, know big trouble explain, this problem is cmake bug? Or my own cmakelist writing has a problem?
  • Related