Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If there's never any source higher than the lx/src directory, then there's no need for the <strong>lx/CMakeLists.txt</strong> file. If there is, it should look something like this:</p> <pre><code>cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(lx) add_subdirectory(src) add_subdirectory(dir1) add_subdirectory(dir2) # And possibly other commands dealing with things # directly in the "lx" directory </code></pre> <p>...where the subdirectories are added in library dependency order. Libraries that depend on nothing else should be added first, and then libraries that depend on those, and so on.</p> <p><strong>lx/src/CMakeLists.txt</strong></p> <pre><code>cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(lx_exe) add_subdirectory(util) add_subdirectory(js) add_subdirectory(server) set(lx_source_files conf.c lx.c) add_executable(lx ${lx_source_files}) target_link_libraries(lx server) # also transitively gets the "js" and "util" dependencies </code></pre> <p><strong>lx/src/util/CMakeLists.txt</strong></p> <pre><code>set(util_source_files etc.c etc.h str.c str.h ) add_library(util ${util_source_files}) </code></pre> <p><strong>lx/src/js/CMakeLists.txt</strong></p> <pre><code>set(js_source_files interp.c interp.h js.c js.h ) add_library(js ${js_source_files}) target_link_libraries(js util) </code></pre> <p><strong>lx/src/server/CMakeLists.txt</strong></p> <pre><code>set(server_source_files request.c request.h server.c server.h ) add_library(server ${server_source_files}) target_link_libraries(server js) # also transitively gets the "util" dependency </code></pre> <p>Then, in a command prompt:</p> <pre><code>mkdir lx/bin cd lx/bin cmake .. # or "cmake ../src" if the top level # CMakeLists.txt is in lx/src make </code></pre> <p>By default, the lx executable will end up in the "lx/bin/src" directory using this exact layout. You can control what directory it ends up in by using the RUNTIME_OUTPUT_DIRECTORY target property and the set_property command.</p> <p><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY" rel="noreferrer">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY</a></p> <p><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property" rel="noreferrer">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property</a></p> <p>Refer to target_link_libraries libs either by CMake target name, if the lib is built as a CMake target via add_library, or by full path to the library file otherwise.</p> <p>See also, the output of "cmake --help-command target_link_libraries", or any other cmake command, and the full online documentation for cmake commands found here:</p> <p><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_Commands" rel="noreferrer">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_Commands</a></p> <p><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:target_link_libraries" rel="noreferrer">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:target_link_libraries</a></p>
 

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