@Gitter :gitter.im/cnruby
Code ID: basic_111
Code Name: Hello, C++ Library!
- The Structure of Project "basic_111"
- Build and Run The Project
- Analyze The Build of Project
- Final Summary
- References
- The Project's Commands
git clone https://github.com/cnruby/w3h1_cmake.git basic_111
cd basic_111
git checkout basic_111
code .
#<!-- markdown-exec(cmd:cat tree.txt) -->#
.
├── CMakeLists.txt
├── include
│ └── local
│ ├── CMakeLists.txt
│ └── header.hxx
└── src
├── CMakeLists.txt
└── main.cxx
#<!-- /markdown-exec -->
#<!-- markdown-exec(cmd:cat src/CMakeLists.txt) -->#
add_executable(
main_111
main.cxx
)
target_link_libraries(main_111 lib_111)
#<!-- /markdown-exec -->
#<!-- markdown-exec(cmd:cat include/local/CMakeLists.txt) -->#
add_library(lib_111 INTERFACE)
target_include_directories(
lib_111
INTERFACE
${PROJECT_SOURCE_DIR}/include/local/
)
#<!-- /markdown-exec -->
cmake --build build/ --clean-first -v
./bin/main_111
# compile
c++ -I./include/local -std=gnu++1z -MD -MT bin/main.cxx.o -MF bin/main.cxx.o.d \
-o bin/main.cxx.o -c ./src/main.cxx -v
# link
c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
bin/main.cxx.o -o ./bin/main_111 -v
@Gitter: gitter.im/cnruby
@Github: github.com/cnruby
@Twitter: twitter.com/cnruby
@Blogspot: cnruby.blogspot.com
- https://cmake.org/cmake/help/latest/command/include_directories.html
- https://cmake.org/cmake/help/latest/command/target_include_directories.html
- https://stackoverflow.com/questions/31969547/what-is-the-difference-between-include-directories-and-target-include-directorie
- https://stackoverflow.com/questions/26243169/cmake-target-include-directories-meaning-of-scope
- https://gitlab.kitware.com/cmake/cmake/issues/19802
- https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
- http://mariobadr.com/creating-a-header-only-library-with-cmake.html
- https://stackoverflow.com/questions/18869282/initialize-char
- https://stackoverflow.com/questions/2587349/initializing-char-and-char-pointers
- https://stackoverflow.com/questions/18963888/c-char-initialization-in-constructor
- https://stackoverflow.com/questions/13703647/how-to-properly-add-include-directories-with-cmake
- https://stackoverflow.com/questions/9834067/difference-between-char-and-const-char
- https://stackoverflow.com/questions/2186246/what-is-o-file
- https://www.online-convert.com/file-format/o
ruby format-codes.rb
cmake -GNinja -Bbuild/
cmake --build build/ --clean-first -v
./bin/main_111
rm ./bin/main.* ./bin/main_*
c++ -I./include/local -std=gnu++1z -MD -MT bin/main.cxx.o -MF bin/main.cxx.o.d \
-o bin/main.cxx.o -c ./src/main.cxx
c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
bin/main.cxx.o -o ./bin/main_111
c++ -I./include/local -std=gnu++1z -MD -MT bin/main.cxx.o -MF bin/main.cxx.o.d \
-o bin/main.cxx.o -c ./src/main.cxx -v
c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
bin/main.cxx.o -o ./bin/main_111 -v