Adding simple example
This commit is contained in:
parent
f27230808e
commit
1a3e22c1e1
@ -11,6 +11,7 @@
|
||||
* [Communicating with your code](chapters/basics/comms.md)
|
||||
* [How to Structure Your Project](chapters/basics/structure.md)
|
||||
* [Running Other Programs](chapters/basics/programs.md)
|
||||
* [A Simple Example](chapters/basics/example.md)
|
||||
* [Adding Features](chapters/features.md)
|
||||
* [C++11 and Beyond](chapters/features/cpp11.md)
|
||||
* [Small but common needs](chapters/features/small.md)
|
||||
|
8
chapters/basics/example.md
Normal file
8
chapters/basics/example.md
Normal file
@ -0,0 +1,8 @@
|
||||
# A simple example
|
||||
|
||||
This is a simple yet complete example of a proper CMakeLists. For this program, we have one library (MyLibExample) with a header file and a source file,
|
||||
and one application, MyExample, with one source file.
|
||||
|
||||
2[import:'main', lang:'cmake'](../../examples/simple-project/CMakeLists.txt)
|
||||
|
||||
The complete example is available in examples folder in the Modern CMake git repository.
|
@ -1,3 +1,5 @@
|
||||
## [main]
|
||||
|
||||
# Almost all CMake files should start with this
|
||||
# You should always specify a range with the newest
|
||||
# and oldest tested versions of CMake. This will ensure
|
||||
@ -30,7 +32,10 @@ add_executable(MyExample simple_example.cpp)
|
||||
# even flags, so linking a target that does not exist will not give a configure-time error.
|
||||
target_link_libraries(MyExample PRIVATE MyLibExample)
|
||||
|
||||
## [main]
|
||||
|
||||
# This part is so the Modern CMake book can verify this example builds. For your code,
|
||||
# you'll probably want tests too
|
||||
enable_testing()
|
||||
add_test(NAME MyExample COMMAND MyExample)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user