Sorry I hit tab and accidently pressed enter and gmail sent the email..

> <programmer2...@gmail.com> wrote:
>> Hi,
>>
>> I'm trying to use Cmake for a cross-platform application. I'm trying to
>> configure it for Visual Studio on Windows, since that's what I use to
>> develop in.
>>
>> Is there a better way of adding files, though? I can't really add files from
>> within Visual Studio, it appears, because it'd go in the build directory.
>>
> This will not add them to the CMakeLists.txt either so its really no
> good use to add files in Visual Studio itself. I just associate
> CMakeLists.txt to Notepad++ and then click on that in the Solution
> View and then edit the CMakeLists.txt file and have Notepad++ create
> the files.
>
> http://notepad-plus.sourceforge.net/uk/site.htm
>
>>
>> Also, is there any better way to actually replicate the folder structure of
>> the source code?
>>
> I am confused at that question.
> I have my code organized as
>
>
Project
   Src
   Include
   Libraries
        Internal
           someLibrary
               Src
               Include
           someOtherLibrary
               Src
               Include


>
>>
>> I might just move to using vim because using Visual Studio is quite a pain
>> at this point, but in case someone else wants to build it or contribute to
>> the code, developing in Visual Studio, I'd like to make it as easy as
>> possible.
>>
>> I'm just starting out with this, but here's my current CMakeLists.txt in the
>> src directory.
>>

Here is an example of mine..

PROJECT(LungAnalysis)

set (LungAnalysis_VERSION_MAJOR 0)
set (LungAnalysis_VERSION_MINOR 4)

#########################################################################################

set( LUNG_ANALYSIS_SRC ${PROJECT_SOURCE_DIR} )
set( LUNG_ANALYSIS_BINARY ${PROJECT_BINARY_DIR} )

add_subdirectory(Libraries)

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)

option (USE_BZ_AIRWAY_ANALYSIS "Use Bin Zheng's Airway Analysis" ON)
option (USE_SCP_LS "Use Sean Choel Park's Lung Segmentation" ON)
option (DUMP_DICOM_HEADERS "Dump DICOM headers" OFF)
option (DUMP_DEBUG_IMAGES "Dump DEBUG Images" OFF)
option (DUMP_SERIES_DEBUG_INFO "Dump the dicom series debug info." OFF)
option (USE_QTBASICUTILS        "Use QTBasicUtils" ON)
option (USE_kwCoreLib           "Use kwCoreLib" ON)
option (USE_DEVELOMPENT         "Build developement code and test projects" ON)
option (USE_CMD_LINE            "Build Lung Analysis with command line support" 
ON)
option (USE_FILTERS                     "Build Lung Analysis with filter 
support" ON)
option (MAKE_DEBUGRELEASE       "Add support for building a Release Target
with debug info" ON)
option (USE_LA_BASE_LIB         "Add support for laBase library." ON)
option (USE_LA_RESULTS          "Add support for results." ON)
option (USE_LA_DOCVIEW          "Add support for documents and views." ON)
option (USE_LA_ANALYSIS         "Add support for the analysis package." ON)
option (USE_LA_GUI                      "Add support for the GUI package." ON)
option (USE_LA_DICOM            "Add support for the DICOM." ON)
option (USE_ideality            "Use the ideality library." ON)
option (USE_MSVC_PCH            "Use precompiled headers in MSVC." ON)

option (DISABLE_OPENGL                          "Disable opengl. This will 
disable the
display of images." OFF)
option (DISABLE_RESULT_TIMESTAMPS       "Don't save the timetamp in the
filenames for the results" ON)
option (DISABLE_SLICE_THICK_IN_NAME     "Don't put the slice thickness in
the document name." ON)

IF(DISABLE_OPENGL)
        ADD_DEFINITIONS(-DDISABLE_OPENGL)
ENDIF(DISABLE_OPENGL)

IF(DISABLE_RESULT_TIMESTAMPS)
        ADD_DEFINITIONS(-DDISABLE_RESULT_TIMESTAMPS)
ENDIF(DISABLE_RESULT_TIMESTAMPS)

IF(DISABLE_SLICE_THICK_IN_NAME)
        ADD_DEFINITIONS(-DDISABLE_SLICE_THICK_IN_NAME)
ENDIF(DISABLE_SLICE_THICK_IN_NAME)

IF (MAKE_DEBUGRELEASE)
SET (CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo" CACHE
STRING "Debug;Release;RelWithDebInfo" FORCE)
ELSE(MAKE_DEBUGRELEASE)
SET (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING
"Debug;Release" FORCE)
ENDIF (MAKE_DEBUGRELEASE)

IF(WIN32)

#The following command changes \ to / in the Program Files Path so
CMake will not complain
#about bad escape sequences.
string (REPLACE "\\" "/" PGM_FILES $ENV{PROGRAMFILES})

SET (CMAKE_INSTALL_PREFIX ${PGM_FILES}/UPMC/${CMAKE_PROJECT_NAME}
CACHE STRING "Default Install Path" FORCE)
ENDIF(WIN32)

configure_file (
        "${LUNG_ANALYSIS_SRC}/LungAnalysisConfig.h.in"
        "${LUNG_ANALYSIS_BINARY}/LungAnalysisConfig.h"
)

INCLUDE_DIRECTORIES(${LUNG_ANALYSIS_BINARY})

IF(WIN32)
    SET(CMAKE_CXX_FLAGS "/WL /MP /GR /EHsc" )
    SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /MANIFEST
/STACK:10000000 /machine:I386")
        
        #IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
      SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
    #ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4)

        ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)

IF(DUMP_DICOM_HEADERS)
        ADD_DEFINITIONS(-DDUMP_DICOM_HEADERS)
ENDIF(DUMP_DICOM_HEADERS)

IF(DUMP_SERIES_DEBUG_INFO)
        ADD_DEFINITIONS(-DDUMP_DICOM_SERIES_DEBUG_INFO)
ENDIF(DUMP_SERIES_DEBUG_INFO)

IF(DUMP_DEBUG_IMAGES)
        ADD_DEFINITIONS(-DDUMP_DEBUG_IMAGES_ALWAYS)
ENDIF(DUMP_DEBUG_IMAGES)

ADD_DEFINITIONS(-DNEED_WL_FILTER)

IF(USE_CMD_LINE)
        ADD_DEFINITIONS(-DUSE_COMMAND_LINE)
ENDIF(USE_CMD_LINE)

IF(USE_BZ_AIRWAY_ANALYSIS)
        option (BZ_AIRWAY_USE_SLICE_ROI_MASK "Airway analysis takes slices
that are cropped to match the Lung_Image_Mask" ON)
        IF(BZ_AIRWAY_USE_SLICE_ROI_MASK)
        ADD_DEFINITIONS(-DBZ_AIRWAY_USE_SLICE_ROI_MASK)
        ENDIF(BZ_AIRWAY_USE_SLICE_ROI_MASK)
        FIND_PACKAGE( BZ_Airway REQUIRED )
        include(${BZ_AIRWAY_USE_FILE})
ENDIF (USE_BZ_AIRWAY_ANALYSIS)

IF(USE_SCP_LS)
        FIND_PACKAGE( SCP_LS REQUIRED )
    include(${SCP_LS_USE_FILE})
ENDIF (USE_SCP_LS)

IF(USE_kwCoreLib)
        set(USE_kwCoreLib_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/External/kwCoreLib/kwCoreLibConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/External/kwCoreLib/kwCoreLibUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/External/kwCoreLib)
ENDIF(USE_kwCoreLib)

IF(USE_ideality)
        set(USE_ideality_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/External/ideality/idealityConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/External/ideality/idealityUSE.cmake)
        include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/External/ideality)
ENDIF(USE_ideality)

IF(USE_FILTERS)
        set(USE_laFilters_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laFilters/laFiltersConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laFilters/laFiltersUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laFilters)
ENDIF(USE_FILTERS)

IF(USE_LA_BASE_LIB)
        set(USE_laBase_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laBase/laBaseConfig.cmake)
        include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laBase/laBaseUSE.cmake)
        include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laBase)
ENDIF(USE_LA_BASE_LIB)

IF(USE_LA_RESULTS)
        set(USE_laResults_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laResults/laResultsConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laResults/laResultsUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laResults)
ENDIF(USE_LA_RESULTS)

IF(USE_LA_DOCVIEW)
        set(USE_laDocView_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laDocView/laDocViewConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laDocView/laDocViewUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laDocView)
ENDIF(USE_LA_DOCVIEW)

IF(USE_LA_GUI)
        set(USE_laGUIView_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laGUI/laGUIConfig.cmake)
        include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laGUI/laGUIUSE.cmake)
        include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laGUI)
ENDIF(USE_LA_GUI)

IF(USE_LA_DICOM)
        set(USE_laDICOMView_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laDICOM/laDICOMConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laDICOM/laDICOMUSE.cmake)
        include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laDICOM)
ENDIF(USE_LA_DICOM)

IF(USE_LA_ANALYSIS)
        set(USE_laAnalysis_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laAnalysis/laAnalysisConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laAnalysis/laAnalysisUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laAnalysis)
ENDIF(USE_LA_ANALYSIS)

IF(USE_CMD_LINE)
        option(DEBUG_CMD_LINE "Debug the command line." OFF)
        if(DEBUG_CMD_LINE)
                add_definitions(-DDEBUG_CMD_LINE)
        endif(DEBUG_CMD_LINE)

    set(USE_laBatchProcessing_TREE 1)
        
include(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laBatchProcessing/laBatchProcessingConfig.cmake)
        
include(${LUNG_ANALYSIS_SRC}/Libraries/Internal/laBatchProcessing/laBatchProcessingUSE.cmake)
        
include_directories(${LUNG_ANALYSIS_BINARY}/Libraries/Internal/laBatchProcessing)
ENDIF(USE_CMD_LINE)

IF(USE_DEVELOMPENT)
        add_subdirectory(Development)
ENDIF(USE_DEVELOMPENT)

IF(USE_QTBASICUTILS)
        FIND_PACKAGE( QtBasicUtils REQUIRED )
    include(${QTBASICUTILS_USE_FILE})
ENDIF (USE_QTBASICUTILS)

IF(COMMAND cmake_policy)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

SET (LIBRARY_OUTPUT_PATH ${LUNG_ANALYSIS_BINARY}/bin CACHE INTERNAL
"Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${LUNG_ANALYSIS_BINARY}/bin CACHE INTERNAL
"Single output directory for building all executables.")

FIND_PACKAGE( Qt4 REQUIRED )
set(QT_USE_QTNETWORK true)

FIND_PACKAGE( ITK REQUIRED )
INCLUDE( ${ITK_USE_FILE} )

FIND_PACKAGE( VTK REQUIRED )
INCLUDE( ${VTK_USE_FILE} )

FIND_PACKAGE( Boost REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )

INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} . Include)

INCLUDE( ${QT_USE_FILE} )
SET( UPMC_LA_SRCS
        ./src/main.cxx
        ./src/mainwindow.cxx
        ./src/textwidget.cxx
        ./src/upmcLungApp.cxx
        ./src/AppSettingsDlg.cxx
        ./src/laFileMenu.cxx
  )

SET( UPMC_LA_MOC_HDR
        ./Include/mainwindow.h
        ./Include/textwidget.h
        ./Include/upmcLungApp.h
        ./Include/AppSettingsDlg.h
        ./Include/laFileMenu.h
)

SET( UPMC_LA_HDRS
        ./Include/ClickedPointEvent.h
        ./Include/VolumeDataExport.h
        ./Include/LungAnalysisConstants.h
        ./Include/sliceOrientation.h
)

if (MSVC)
        if (USE_MSVC_PCH)
        
                set_source_files_properties(LungAnalysisPCH.cxx
                        PROPERTIES
                        COMPILE_FLAGS "/YcLungAnalysisPCH.h"
                        )
                foreach( src_file ${UPMC_LA_SRCS} )
                        set_source_files_properties(
                                ${src_file}
                                PROPERTIES
                                COMPILE_FLAGS "/YuLungAnalysisPCH.h"
                                )
                endforeach( src_file ${UPMC_LA_SRCS} )
                
                list(APPEND UPMC_LA_SRCS LungAnalysisPCH.cxx)
                list(APPEND UPMC_LA_HDRS LungAnalysisPCH.h)

        endif(USE_MSVC_PCH)
endif (MSVC)

# some .ui files
SET( UPMC_LA_UIS
        ./rc/AppSettings.ui
)

# and finally an resource file
SET( UPMC_LA_RCS
        ./rc/LungAnalysis.qrc
)

# this command will generate rules that will run rcc on all files from
UPMC_LA_RCS
# in result UPMC_LA_RC_SRCS variable will contain paths to files produced by rcc
QT4_ADD_RESOURCES( UPMC_LA_RC_SRCS ${UPMC_LA_RCS} )

# and finally this will run moc:
QT4_WRAP_CPP( UPMC_LA_MOC_SRCS ${UPMC_LA_MOC_HDR} )

# this will run uic on .ui files:
QT4_WRAP_UI( UPMC_LA_UI_HDRS ${UPMC_LA_UIS} )

LINK_LIBRARIES ( LungAnalysis ${UPMC_EXTERNAL_LIBS} ${QT_LIBRARIES}
ITKCommon ITKBasicFilters
        ITKIO QVTK vtkCommon
)

ADD_EXECUTABLE( LungAnalysis ${UPMC_LA_SRCS} ${UPMC_LA_MOC_SRCS}
${UPMC_LA_HDRS}
        ${UPMC_LA_MOC_HDR} ${UPMC_LA_RC_SRCS} ${UPMC_LA_UI_HDRS}
)
_______________________________________________
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

Reply via email to