X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=README.cmake;h=767f9c779c6a3bf476c13963a5da2c6f89a3ef8f;hb=4d4e1a237165768e9abcf98a4251a9cefacb5093;hp=c74b4a5582e8a848619f07fd2846007bec3c3f33;hpb=c6062ad93cf3bfbffb6dec63cd6844167bb56980;p=flightgear.git diff --git a/README.cmake b/README.cmake index c74b4a558..767f9c779 100644 --- a/README.cmake +++ b/README.cmake @@ -1,4 +1,7 @@ Getting started with CMake +========================== + +[For Windows build instructions see README.msvc] (These instructions apply to Unix-like systems, including Cygwin and Mac. To build using Visual Studio or some other IDE supported by CMake, most of the @@ -8,8 +11,8 @@ Always compile in a separate directory to the code. For example, if the code (eg, from Git) is at /home/curt/projects/flightgear, you might create /home/curt/projects/fgbuild. Change into the new directory, and run - cmake ../flightger - + cmake ../flightgear + To generate standard Unix Makefiles in fgbuild. Probably you want to specify an install prefix: @@ -37,7 +40,7 @@ usually simpler. By default, we select a release build. To create a debug build, use cmake ../flightgear -DCMAKE_BUILD_TYPE=Debug - + (or MinSizeRel, or RelWithDbg) Debug builds will automatically use corresponding debug builds of required @@ -62,21 +65,23 @@ configurations, eg To set an optional feature, do - cmake ../flightgear -DFEATURE_NAME=ON + cmake ../flightgear -DFEATURE_NAME=ON (or 'OFF' to disable ) To see the variables that can be configured / are currently defined, you can run one of the GUI front ends, or the following command: - cmake ../flighgear -L + cmake ../flightgear -L Add 'A' to see all the options (including advanced options), or 'H' to see the help for each option (similar to running configure --help under autoconf): cmake ../flightgear -LH + Build Targets +============= For a Unix makefile build, 'make dist', 'make uninstall' and 'make test' are all available and should work as expected. 'make clean' is also as normal, @@ -93,7 +98,7 @@ For target conditional files, you can append to the SOURCES or HEADERS lists inside an if() test, for example: if(APPLE) - list(APPEND SOURCES extraFile1.cxx extraFile2.cxx) + list(APPEND SOURCES extraFile1.cxx extraFile2.cxx) endif() Setting include directories @@ -111,11 +116,11 @@ Use set_target_property(), for example set_target_property(fgfs PROPERTIES COMPILE_DEFINITIONS FOO BAR=1) - + You can set a property on an individual source file: set_property(SOURCE myfile.cxx PROPERTY COMPILE_FLAGS "-Wno-unsigned-compare") - + Detecting Features / Libraries For most standard libraries (Gtk, wxWidget, Python, GDAL, Qt, libXml, Boost), @@ -126,7 +131,7 @@ cmake provides a standard helper. To see the available modules, run: In the root CMakeLists file, use a statement like: find_package(OpenGL REQUIRED) - + Each package helper sets various variables such aaa_FOUND, aaa_INCLUDE_DIR, and aaa_LIBRARY. Depending on the complexity of the package, these variables might have different names (eg, OPENSCENEGRAPH_LIBRARIES). @@ -138,18 +143,19 @@ directory, eg /usr/share/cmake/modules on Unix systems. Note libraries support by pkg-config can be handled directly, with no need to create a custom FindABC helper. - + Adding a new executable target add_executable(myexecutable ${SOURCES} ${HEADERS}) target_link_libraries(myexecutable .... libraries ... ) install(TARGETS myexecutable RUNTIME DESTINATION bin) - + (If the executable should not be installed, omit the final line above) If you add an additional line add_test(testname ${EXECUTABLE_OUTPUT_PATH}/myexecutable) - + Then running 'make test' will run your executable as a unit test. The executable should return either a success or failure result code. +