@Gitter :gitter.im/cnruby
Code ID: basic_137
Code Name: Hello, Object Library!
- About The Project
- Explain
C++
andCMake
Code - A Demonstration of Building Project
- Final Summary
- References
// ./src/main.cxx
#include <iostream>
#include "config.hxx"
#include "header.hxx"
#include "macro.hxx"
int main(int, char**) {
std::cout << "Project ID:\t\t\t" << PROJECT_NAME << std::endl;
std::cout << "Project Code:\t\t\t" << PROJECT_DESCRIPTION << std::endl;
std::cout << "Project Version:\t\t" << MACRO_VERSION << std::endl << std::endl;
Header header;
header.hello("Library");
# ./src/one.cmake
add_executable(
${MAIN_NAME}_one
main.cxx
)
# ./src/three.cmake
add_library(
${MAIN_NAME}_o
OBJECT main.cxx
)
add_executable(
${MAIN_NAME}_three
)
target_link_libraries(
${MAIN_NAME}_three
${LIB_NAME}_o ${MAIN_NAME}_o
)
# ./lib/one.cmake
add_library(
${LIB_NAME}_a
STATIC header.cxx
)
# ./lib/three.cmake
add_library(
${LIB_NAME}_o
OBJECT header.cxx
)
add_library(
${LIB_NAME}_ar STATIC
)
target_link_libraries(
${LIB_NAME}_ar
${LIB_NAME}_o
)
@Gitter: gitter.im/cnruby
@Github: github.com/cnruby
@Twitter: twitter.com/cnruby
@Blogspot: cnruby.blogspot.com
- https://stackoverflow.com/questions/8249945/what-is-object-in-object-file-and-why-is-it-called-this-way
- https://qiita.com/mrk_21/items/57075ce36f49ce0aacf4
- https://stackoverflow.com/questions/35696103/cmake-wildcard-for-target-objects
- https://stackoverflow.com/questions/44767099/linking-cmake-interface-libraries-with-object-libraries
- https://stackoverflow.com/questions/49265945/cmake-append-objects-from-different-cmakelists-txt-into-one-library
- https://stackoverflow.com/questions/58969829/cmake-object-files-of-executable-in-custom-command
- https://github.com/dev-cafe/cmake-cookbook
- https://www.dealii.org/9.1.1/users/cmakelists.html
- https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
- https://stackoverflow.com/questions/50684930/how-to-collect-object-files-o-in-a-particular-directory-with-cmake
- https://stackoverflow.com/questions/48296061/cmakes-objects-output-folder-variable
- https://stackoverflow.com/questions/29884856/how-to-get-path-to-object-files-with-cmake-for-both-multiconfiguration-generator
git clone https://github.com/cnruby/w3h1_cmake.git basic_137
cd basic_137
git checkout basic_137
code .
# ./docs/output/tree.txt
.
├── cmake
│ ├── CMakeLists.txt
│ ├── config.h.in
│ ├── GetOutput.cmake
│ └── Initialize.cmake
├── CMakeLists.txt
├── config
├── config.hxx
│ └── macro.hxx
└── src
├── CMakeLists.txt
├── main.cxx
├── one.cmake
└── three.cmake