mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-18 12:14:36 +03:00
54 lines
1.3 KiB
CMake
54 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
|
|
project(cmake_examples_install)
|
|
|
|
############################################################
|
|
# Create a library
|
|
############################################################
|
|
|
|
#Generate the shared library from the library sources
|
|
add_library(cmake_examples_inst SHARED
|
|
src/Hello.cpp
|
|
)
|
|
|
|
target_include_directories(cmake_examples_inst
|
|
PUBLIC
|
|
${PROJECT_SOURCE_DIR}/include
|
|
)
|
|
|
|
############################################################
|
|
# Create an executable
|
|
############################################################
|
|
|
|
# Add an executable with the above sources
|
|
add_executable(cmake_examples_inst_bin
|
|
src/main.cpp
|
|
)
|
|
|
|
# link the new hello_library target with the hello_binary target
|
|
target_link_libraries( cmake_examples_inst_bin
|
|
PRIVATE
|
|
cmake_examples_inst
|
|
)
|
|
|
|
############################################################
|
|
# Install
|
|
############################################################
|
|
|
|
# Binaries
|
|
install (TARGETS cmake_examples_inst_bin
|
|
DESTINATION bin)
|
|
|
|
# Library
|
|
# Note: may not work on windows
|
|
install (TARGETS cmake_examples_inst
|
|
LIBRARY DESTINATION lib)
|
|
|
|
# Header files
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
|
DESTINATION include)
|
|
|
|
# Config
|
|
install (FILES cmake-examples.conf
|
|
DESTINATION etc)
|