Skip to content

Commit

Permalink
cmake: Add option to disable install
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jul 23, 2019
1 parent 22ed657 commit b413c2e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
31 changes: 17 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -70,17 +68,22 @@ configure_package_config_file(
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)

install(
EXPORT evmcTargets
NAMESPACE evmc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/evmcConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/evmcConfigVersion.cmake
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::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/evmcConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/evmcConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc
)
endif()

if(WIN32)
set(CPACK_GENERATOR ZIP)
Expand Down
13 changes: 7 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


install(TARGETS evmc-example-vm
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(EVMC_INSTALL)
install(TARGETS evmc-example-vm
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()
4 changes: 3 additions & 1 deletion lib/instructions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>)

install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(EVMC_INSTALL)
install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
4 changes: 3 additions & 1 deletion lib/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ target_include_directories(loader PUBLIC
)
target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS})

install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(EVMC_INSTALL)
install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
5 changes: 3 additions & 2 deletions test/vmtester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
target_link_libraries(evmc-vmtester PRIVATE evmc loader evmc-example-host GTest::gtest)
set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")


install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if(EVMC_INSTALL)
install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

set(prefix ${PROJECT_NAME}/vmtester)

Expand Down

0 comments on commit b413c2e

Please sign in to comment.