cmake: Add option to disable install

This commit is contained in:
Paweł Bylica 2019-07-23 11:57:21 +02:00
parent 1a45ce6910
commit 56ceca3b29
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
5 changed files with 34 additions and 24 deletions

View File

@ -9,6 +9,7 @@ if(TARGET evmc)
return()
endif()
option(EVMC_INSTALL "Enable EVMC installation (e.g. make install)" ON)
option(EVMC_TESTING "Build EVMC examples, tests and test tools (i.e. everything)" OFF)
option(EVMC_TEST_TOOLS "Build EVMC test tools" ${EVMC_TESTING})
if(EVMC_TESTING OR EVMC_TEST_TOOLS)
@ -44,9 +45,6 @@ set(include_dir ${PROJECT_SOURCE_DIR}/include)
add_library(evmc INTERFACE)
add_library(evmc::evmc ALIAS evmc)
target_include_directories(evmc INTERFACE $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>)
install(TARGETS evmc EXPORT evmcTargets)
install(DIRECTORY include/evmc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
add_subdirectory(lib)
@ -70,6 +68,10 @@ configure_package_config_file(
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)
if(EVMC_INSTALL)
install(TARGETS evmc EXPORT evmcTargets)
install(DIRECTORY include/evmc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
EXPORT evmcTargets
NAMESPACE evmc::
@ -82,6 +84,7 @@ install(
cmake/EVMC.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)
endif()
if(WIN32)
set(CPACK_GENERATOR ZIP)

View File

@ -29,9 +29,10 @@ set_source_files_properties(example_vm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_
add_executable(evmc-example example.c)
target_link_libraries(evmc-example PRIVATE evmc-example-host evmc-example-vm evmc)
if(EVMC_INSTALL)
install(TARGETS evmc-example-vm
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()

View File

@ -13,4 +13,6 @@ add_library(evmc::instructions ALIAS instructions)
set_target_properties(instructions PROPERTIES OUTPUT_NAME evmc-instructions)
target_include_directories(instructions PUBLIC $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>)
if(EVMC_INSTALL)
install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -18,4 +18,6 @@ target_include_directories(loader PUBLIC
)
target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS})
if(EVMC_INSTALL)
install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -12,7 +12,9 @@ set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_
add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester)
if(EVMC_INSTALL)
install(TARGETS evmc-vmtester EXPORT evmcTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
set(prefix ${PROJECT_NAME}/vmtester)