Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to build a project through CMakeLists mother?
    primarykey
    data
    text
    <p>Suppose my project has several sub-modules, and the architecture is:</p> <ul> <li><strong>/CMakeLists.txt</strong> (<em>Base</em>) -> Call subdirectory</li> <li><strong>/projectName/CMakeLists.txt</strong> (<em>Child</em>) -> Call subdirectory moduleName and add main project sources</li> <li><strong>/projectName/xxx.cpp</strong></li> <li><strong>/projectName/moduleName/CMakeLists.txt</strong> (Child of Child) -> Add the module sources</li> <li><strong>/projectName/moduleName/xxx.cpp</strong></li> </ul> <p>I could just do with a single CMakeLists adding many sources, but I think the CMake has been made ​​to work this way. </p> <p>My CMakeLists.txt:</p> <p><strong>Main CMakeLists.txt:</strong></p> <pre><code># CMake Minimum Version Required ( &gt;= 2.8 ) cmake_minimum_required ( VERSION 2.8 ) # CMake Project Name and Languages project ( LightUpdater C CXX ) # Add Compiler Definitions add_definitions ( -Wall -Werror ) # Include source headers include_directories ( lightupdater ) # Add custom module folder set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}" ) set ( EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR} ) # Binary output folder # Setup project variables set ( LIGHTUPDATER_OUTPUT lightupdater ) set ( LIGHTUPDATER_SOURCES "" ) # Add Source Subdirectory add_subdirectory ( lightupdater ) </code></pre> <p><strong>/projectName/CMakeLists.txt</strong></p> <pre><code># Setup the source code files list ( APPEND LIGHTUPDATER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lightupdater.cpp ) # Add Modules add_subdirectory ( interface ) </code></pre> <p><strong>/projectName/moduleName/CMakeLists.txt</strong></p> <pre><code>list ( APPEND LIGHTUPDATER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gui.cpp ) # Qt4 # ---------------------------------------------------------------------------------- # Find Qt4 (REQUIRED) find_package( Qt4 REQUIRED ) # Compiler setup include ( ${QT_USE_FILE} ) add_definitions ( ${QT_DEFINITIONS} ) include_directories( ${QT_INCLUDE_DIR} ) # Setup the interface sources set( INTERFACE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/gui.hpp ) # Process headers QT4_WRAP_CPP( INTERFACE_HEADER_MOC ${INTERFACE_HEADER} ) list( APPEND LIGHTUPDATER_SOURCES ${INTERFACE_HEADER_MOC} ) # ---------------------------------------------------------------------------------- # Define Qt Operating System # Created by Renato Utsch # ---------------------------------------------------------------------------------- set( GUI_TYPE "" ) if( APPLE ) set( GUI_TYPE MACOSX_BUNDLE ) elseif( WIN32 ) set( GUI_TYPE WIN32 ) endif() # Compiler call add_executable( ${LIGHTUPDATER_OUTPUT} ${GUI_TYPE} ${LIGHTUPDATER_SOURCES} ) # Linking the 3rd party librarys target_link_libraries( ${LIGHTUPDATER_OUTPUT} ${QT_LIBRARIES} ) </code></pre> <p>I want the calling process to occur in the compiler CMakeLists.txt mother, and not in the module as it is today.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload