![]() Executables and windows dll files go into bin directory, libraries go into lib directory, and public headers go into include directory at the destination. The top-level CMakeLists.txt file references the. In CMake options, add the following line: cmake -DCMAKETOOLCHAINFILE/scripts/buildsystems/vcpkg.cmake You must add this line to each profile separately.Install(TARGETS): to install compiled libraries and their headers in the assigned install directory you set when running cmake -install blah blah. Building, testing, and packaging modular software with modern CMake Radovan Bast, Roberto Di Remigio. Open the Toolchains settings ( File > Settings on Windows and Linux, CLion > Preferences on macOS), and go to the CMake settings ( Build, Execution, Deployment > CMake ). So first compile geo then link it to app executable. Target_link_libraries(): to tell CMake that app is dependent on geo library. Target_include_directories(): is for making source files aware of the location of private headers relative to the project directory. SHARED means a shared library, you can also make a static library with STATIC keyword, or an object file with OBJECT keyword. dll.Īdd_library(): to define a library target, geo. If (MSVC): checking CMake is employing MS Visual C++.ĬMAKE_WINDOWS_EXPORT_ALL_SYMBOLS: This is necessary for MSVC to create a symbol file. To build an example, go to its directory in a terminal and runĬmake_minimum_required ( VERSION 3.23 ) project ( geometry LANGUAGES CXX ) if ( MSVC ) set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON ) endif () add_library ( geo SHARED ) target_include_directories ( geo PRIVATE "$" ) add_subdirectory ( "shape" ) add_subdirectory ( "square" ) add_executable ( app ) target_sources ( app PRIVATE "example/app.cpp" ) target_link_libraries ( app PRIVATE geo ) install ( TARGETS geo FILE_SET HEADERS ) ![]()
0 Comments
Leave a Reply. |