[CMake] CMake does not find an header file, and ignores the classes found in several other header files.

Rolf Eike Beer eike at sf-mail.de
Fri Aug 3 15:14:39 EDT 2012


Am Freitag, 3. August 2012, 11:31:44 schrieb Toronto Andrew:
> The following is my CMakeLists file:
> 
> PROJECT(CppSampleQt01)
> FIND_PACKAGE(Qt4 REQUIRED)
> 
> FIND_LIBRARY(SIMPLONLIB lv.simplon lib)
> FIND_LIBRARY(SIMPLONIMGPROC lv.simplon.imgproc lib)
> 
> SET(CppSampleQt01_SOURCES include/lv.simplon.class.cpp camera.cpp main.cpp
> mainwindow.cpp osdep.cpp paint.cpp)
> SET(CppSampleQt01_HEADERS include/lv.simplon.class.h camera.h mainwindow.h
> osdep.h paint.h)
> SET(CppSampleQt01_RESOURCES icons.qrc)
> 
> SET(QExtSerialPort_HEADERS QExtSerialPort/src/qextwineventnotifier_p.h
> 						QExtSerialPort/src/qextserialport_p.h
> 						QExtSerialPort/src/qextserialport_global.h
> 						QExtSerialPort/src/qextserialport.h
> 						QExtSerialPort/src/qextserialenumerator_p.h
> 						QExtSerialPort/src/qextserialenumerator.h)
> SET(QExtSerialPort_SOURCES QExtSerialPort/src/qextserialenumerator.cpp
> 					QExtSerialPort/src/qextserialport.cpp
> 					QExtSerialPort/src/qextwineventnotifier_p.cpp)
> 
> if (WIN32)
> 	SET(QExtSerialPort_SOURCES ${QExtSerialPort_SOURCES}
> QExtSerialPort/src/qextserialport_win.cpp)

list(APPEND QExtSerialPort_SOURCES QExtSerialPort/src/qextserialport_win.cpp)

> 	#  add_definitions(-DWINVER=0x0501) # needed for mingw (dbt business??
> 	LINK_LIBRARIES(${QT_QTGUI_LIBRARY} setupapi advapi32 user32)
> endif(WIN32)
> 
> if (UNIX)

elseif?

> 	SET(QExtSerialPort_SOURCES ${QExtSerialPort_SOURCES}
> QExtSerialPort/src/qextserialport_unix.cpp)
> endif (UNIX)
> 
> if (OSX)
> 	LINK_LIBRARIES(framework IOKit)
> 	SET(QExtSerialPort_SOURCES ${QExtSerialPort_SOURCES}
> QExtSerialPort/src/qextserialport_osx.cpp)
> endif (OSX)
> 
> QT4_WRAP_CPP(CppSampleQt01_HEADERS_MOC ${CppSampleQt01_HEADERS}
> ${QExtSerialPort_HEADERS})
> 
> INCLUDE(${QT_USE_FILE})
> ADD_DEFINITIONS(${QT_DEFINITIONS})
> 
> ADD_EXECUTABLE(CppSampleQt01 ${CppSampleQt01_SOURCES}
> 				${QExtSerialPort_SOURCES}
> 				${CppSampleQt01_HEADERS_MOC}
> 				${CppSampleQt01_RESOURCES_RCC})
> 
> TARGET_LINK_LIBRARIES(CppSampleQt01 ${QT_LIBRARIES} ${SIMPLONLIB}
> ${SIMPLONIMGPROC})
> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} include QExtSerialPort/src)

This is likely source of the trouble: only targets after the 
include_directories() line will see it. So you should move it up before the 
add_executable. Also you just pass "include" here, i.e. every compiler 
invocation may interpret that relative to it's current directory. You should 
use absolute paths there, e.g. "${CMAKE_CURRENT_BINARY_DIR}/include".

> And within the QExtSerialPort/src folder you find all the files under
> QExtSerialPort_HEADERS and SOURCES.
> However, I get these:
> 
> QExtSerialPort/src/qextserialport_p.h(0): Note: No relevant classes found.
> No output generated.
> //This does contain a class' declarations.
> QExtSerialPort/src/qextserialport_global.h(0): Note: No relevant classes
> found. No output generated.
> //This too contains a class' declarations.
> QExtSerialPort/src/qextserialenumerator_p.h(0): Note: No relevant classes
> found. No output generated.
> //Same thing.

You pass it to QT4_WRAP_CPP, so moc tries to run on it. Either don't do it or 
just ignore these lines.

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120803/c815c4f7/attachment.pgp>


More information about the CMake mailing list