mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
update CMake to have namespaced stuff
This commit is contained in:
parent
7f1c2e3ecf
commit
db927c5159
|
@ -139,6 +139,11 @@ CMAKE_DEPENDENT_OPTION(TESTS_DYNAMIC_LOADING_EXAMPLES "Enable build of dynamic l
|
||||||
# # # sol2 Library
|
# # # sol2 Library
|
||||||
# # Add a target for sol2's library to be included by external users
|
# # Add a target for sol2's library to be included by external users
|
||||||
add_library(sol2 INTERFACE)
|
add_library(sol2 INTERFACE)
|
||||||
|
add_library(sol2::sol2 ALIAS sol2)
|
||||||
|
set_target_properties(sol2
|
||||||
|
PROPERTIES
|
||||||
|
EXPORT_NAME sol2::sol2)
|
||||||
|
|
||||||
target_include_directories(sol2 INTERFACE
|
target_include_directories(sol2 INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<INSTALL_INTERFACE:include>)
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
@ -198,8 +203,10 @@ if (PYTHONINTERP_FOUND)
|
||||||
add_custom_target(sol2_single_header ALL
|
add_custom_target(sol2_single_header ALL
|
||||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/single/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/single/sol_forward.hpp")
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/single/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/single/sol_forward.hpp")
|
||||||
add_library(sol2_single INTERFACE)
|
add_library(sol2_single INTERFACE)
|
||||||
|
add_library(sol2::sol2_single ALIAS sol2_single)
|
||||||
set_target_properties(sol2_single
|
set_target_properties(sol2_single
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
|
EXPORT_NAME sol2::sol2_single
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/single")
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/single")
|
||||||
add_dependencies(sol2_single sol2_single_header)
|
add_dependencies(sol2_single sol2_single_header)
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/single/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/single/sol_forward.hpp"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/single/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/single/sol_forward.hpp"
|
||||||
|
@ -221,12 +228,12 @@ endif()
|
||||||
|
|
||||||
# pkg-config support, except on Windows
|
# pkg-config support, except on Windows
|
||||||
if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||||
set(PKGCONFIG_INSTALL_DIR
|
set(PKGCONFIG_INSTALL_DIR
|
||||||
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
||||||
CACHE PATH "Path where sol2.pc is installed")
|
CACHE PATH "Path where sol2.pc is installed")
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sol2.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/sol2.pc" @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sol2.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/sol2.pc" @ONLY)
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sol2.pc" DESTINATION "${PKGCONFIG_INSTALL_DIR}")
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sol2.pc" DESTINATION "${PKGCONFIG_INSTALL_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CI)
|
if (CI)
|
||||||
|
@ -267,7 +274,7 @@ if (DO_TESTS OR DO_EXAMPLES)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
endif()
|
endif()
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
||||||
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
|
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
|
||||||
if (BUILD_LUA)
|
if (BUILD_LUA)
|
||||||
|
@ -287,18 +294,18 @@ if (DO_TESTS OR DO_EXAMPLES)
|
||||||
find_package(LuaBuild ${LUA_VERSION} REQUIRED)
|
find_package(LuaBuild ${LUA_VERSION} REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT LUA_FOUND AND NOT LUABUILD_FOUND)
|
if (NOT LUA_FOUND AND NOT LUABUILD_FOUND)
|
||||||
message(FATAL_ERROR "sol2 Lua \"${LUA_VERSION}\" not found and could not be targeted for building")
|
message(FATAL_ERROR "sol2 Lua \"${LUA_VERSION}\" not found and could not be targeted for building")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # Enable test harness for regular, example or single tests
|
# # Enable test harness for regular, example or single tests
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
# enable ctest
|
# enable ctest
|
||||||
message(STATUS "sol2 testing enabled")
|
message(STATUS "sol2 testing enabled")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # # Examples
|
# # # Examples
|
||||||
# # Enable examples to be built against the library
|
# # Enable examples to be built against the library
|
||||||
if (DO_EXAMPLES)
|
if (DO_EXAMPLES)
|
||||||
|
@ -306,7 +313,7 @@ if (DO_TESTS OR DO_EXAMPLES)
|
||||||
message(STATUS "sol2 adding examples...")
|
message(STATUS "sol2 adding examples...")
|
||||||
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")
|
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # # Tests
|
# # # Tests
|
||||||
# # Add tests here
|
# # Add tests here
|
||||||
if (DO_TESTS)
|
if (DO_TESTS)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user