[CMake] header files with visual studio
Michael Jackson
mike.jackson at bluequartz.net
Thu Nov 4 13:34:43 EDT 2010
I have a macro to help with this:
MACRO (cmp_IDE_SOURCE_PROPERTIES SOURCE_PATH HEADERS SOURCES
INSTALL_FILES)
if (${INSTALL_FILES} EQUAL "1")
INSTALL (FILES ${HEADERS}
DESTINATION include/${SOURCE_PATH}
COMPONENT Headers
)
endif()
STRING(REPLACE "/" "\\\\" source_group_path ${SOURCE_PATH} )
source_group(${source_group_path} FILES ${HEADERS} ${SOURCES})
ENDMACRO (cmp_IDE_SOURCE_PROPERTIES NAME HEADERS SOURCES INSTALL_FILES)
So an example would be:
set (my_HDRS ${PROJECT_SOURCE_DIR}/Headers/MyHeader.h )
set (my_SRCS ${PROJECT_SOURCE_DIR}/Source/MySource.cpp)
set (my_INSTALL "0")
cmp_IDE_SOURCE_PROPERTIES("Source" "${my_HDRS}" "${my_SRCS}" "$
{my_INSTALL}")
add_executable(my ${my_HDRS} ${my_SRCS})
Like, others have stated: You MUST include them in the add_executable
or add_library call. The macro I give above can help keep those files
organized in the Project/Solution file if you want the organization to
mimic the file system for instance. Otherwise CMake will create the
project will all the files in a single "Source" folder.
HTH
___________________________________________________________
Mike Jackson www.bluequartz.net
Principal Software Engineer mike.jackson at bluequartz.net
BlueQuartz Software Dayton, Ohio
On Nov 4, 2010, at 1:26 PM, David Cole wrote:
> That's funny...
>
> Google for "cmake header visual studio" and hit #1 explains it
> pretty well:
> http://stackoverflow.com/questions/1167154/listing-header-files-in-visual-studio-c-project-generated-by-cmake
>
> So do hits #2 through 10.
>
>
> On Thu, Nov 4, 2010 at 11:58 AM, Oliver kfsone Smith <osmith at playnet.com
> > wrote:
>> Checked the faq and googled as much as I could but I couldn't find
>> anything
>> describing how to make visual studio include header files in the
>> solution/project files?
>>
>> - Oliver
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list