[CMake] Bug? Broken header files in Visual C++ 2008 project
John Drescher
drescherjm at gmail.com
Wed Aug 27 19:26:53 EDT 2008
> I don't know how helpful saying this will be, but it works for me, at
> least for CMake 2.6.1 and VS 2008 Express. My same project also builds
> unchanged for 2005 Professional and 2003 Professional, and the headers
> even end up in the right project folders by default (I don't use source
> group or any globbing though). Could you provide an example of how
> you're using add_library or add_executable?
>
My header files appear in the correct place (not with source) in
Visual Studio 2005. I do not have 2008 yet.
Here is an example CMakeLists.txt
PROJECT(CropDICOMImages)
IF(WIN32)
CMAKE_MINIMUM_REQUIRED(VERSION 2.5 FATAL_ERROR)
SET(CMAKE_CXX_FLAGS "/WL /GR /EHsc" )
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(WIN32)
ADD_DEFINITIONS(-DNEED_WL_FILTER)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL
"Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL
"Single output directory for building all executables.")
FIND_PACKAGE( Boost REQUIRED )
FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( ITK REQUIRED )
FIND_PACKAGE( VTK REQUIRED )
INCLUDE( ${ITK_USE_FILE} )
INCLUDE( ${VTK_USE_FILE} )
FIND_PATH(ITK_VTK_GLUE_DIR "CMakeLists.txt" PATHS
${ITK_SOURCE_DIR}/Wrapping/WrapITK/ExternalProjects/ItkVtkGlue)
INCLUDE_DIRECTORIES(${ITK_VTK_GLUE_DIR}/src)
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} . Include)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
INCLUDE( ${QT_USE_FILE} )
SET( UPMC_CROP_SRCS
./src/main.cxx
./src/mainwindow.cxx
./src/textwidget.cxx
./src/CropImage.cxx
)
SET( UPMC_CROP_MOC_HDR
./Include/mainwindow.h
./Include/textwidget.h
)
SET( UPMC_CROP_HDRS
./Include/CropImage.h
)
# some .ui files
SET( UPMC_CROP_UIS
)
# and finally an resource file
SET( UPMC_CROP_RCS
./rc/CropDICOMImages.qrc
)
# this command will generate rules that will run rcc on all files from
UPMC_CROP_RCS
# in result UPMC_CROP_RC_SRCS variable will contain paths to files
produced by rcc
QT4_ADD_RESOURCES( UPMC_CROP_RC_SRCS ${UPMC_CROP_RCS} )
# and finally this will run moc:
QT4_WRAP_CPP( UPMC_CROP_MOC_SRCS ${UPMC_CROP_MOC_HDR} )
# this will run uic on .ui files:
QT4_WRAP_UI( UPMC_CROP_UI_HDRS ${UPMC_CROP_UIS} )
LINK_LIBRARIES ( CropDICOMImages ${QT_LIBRARIES} ITKCommon
ITKBasicFilters ITKIO QVTK vtkCommon
)
ADD_EXECUTABLE( CropDICOMImages ${UPMC_CROP_SRCS}
${UPMC_CROP_MOC_SRCS} ${UPMC_CROP_HDRS}
${UPMC_CROP_MOC_HDR} ${UPMC_CROP_RC_SRCS} ${UPMC_CROP_UI_HDRS}
)
More information about the CMake
mailing list