mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Add options to disable build of tests and examples
Add a source gorup for headers. Detect all cases for "LuaJit"
This commit is contained in:
parent
242ed15777
commit
46e05b92e8
|
@ -8,19 +8,23 @@ include_directories(.)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" "${CMAKE_MODULE_PATH}")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" "${CMAKE_MODULE_PATH}")
|
||||||
|
|
||||||
set(LUA_VERSION "5.3" CACHE STRING "The version of Lua needed (5.1, 5.2, 5.3, luaJIT)")
|
set(LUA_VERSION "5.3" CACHE STRING "The version of Lua needed (5.1, 5.2, 5.3, LuaJIT)")
|
||||||
|
string(TOLOWER ${LUA_VERSION} LUA_VERSION)
|
||||||
if (LUA_VERSION MATCHES "5.1")
|
if (LUA_VERSION MATCHES "5.1")
|
||||||
find_package(Lua 5.1 EXACT REQUIRED)
|
find_package(Lua 5.1 EXACT REQUIRED)
|
||||||
elseif(LUA_VERSION MATCHES "5.2")
|
elseif(LUA_VERSION MATCHES "5.2")
|
||||||
find_package(Lua 5.2 EXACT REQUIRED)
|
find_package(Lua 5.2 EXACT REQUIRED)
|
||||||
elseif(LUA_VERSION MATCHES "5.3")
|
elseif(LUA_VERSION MATCHES "5.3")
|
||||||
find_package(Lua 5.3 EXACT REQUIRED)
|
find_package(Lua 5.3 EXACT REQUIRED)
|
||||||
elseif(LUA_VERSION MATCHES "LuaJIT")
|
elseif(LUA_VERSION MATCHES "luajit")
|
||||||
find_package(LuaJIT REQUIRED)
|
find_package(LuaJIT REQUIRED)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "${LUA_VERSION} is not a supported version for lua.")
|
message(FATAL_ERROR "${LUA_VERSION} is not a supported version for lua.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(TESTS "Enable build of tests" ON)
|
||||||
|
option(EXAMPLES "Enable build of examples" ON)
|
||||||
|
|
||||||
include_directories(${LUA_INCLUDE_DIR})
|
include_directories(${LUA_INCLUDE_DIR})
|
||||||
|
|
||||||
# Features a C++ compiler must have to be used to compile sol2
|
# Features a C++ compiler must have to be used to compile sol2
|
||||||
|
@ -46,11 +50,13 @@ set(CXX_FEATURES cxx_auto_type
|
||||||
|
|
||||||
file(GLOB HEADER_SRCS sol/*.hpp)
|
file(GLOB HEADER_SRCS sol/*.hpp)
|
||||||
set(HEADER_SRCS sol.hpp ${HEADER_SRCS})
|
set(HEADER_SRCS sol.hpp ${HEADER_SRCS})
|
||||||
|
source_group(headers FILES ${HEADER_SRCS})
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors -Wno-noexcept-type -ftemplate-depth=1024")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors -Wno-noexcept-type -ftemplate-depth=1024")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (EXAMPLES)
|
||||||
file(GLOB EXAMPLES_SRC examples/*.cpp)
|
file(GLOB EXAMPLES_SRC examples/*.cpp)
|
||||||
source_group(examples FILES ${EXAMPLES_SRC})
|
source_group(examples FILES ${EXAMPLES_SRC})
|
||||||
foreach(example_source_file ${EXAMPLES_SRC})
|
foreach(example_source_file ${EXAMPLES_SRC})
|
||||||
|
@ -61,7 +67,9 @@ foreach(example_source_file ${EXAMPLES_SRC})
|
||||||
target_compile_features(${example_name} PUBLIC ${CXX_FEATURES})
|
target_compile_features(${example_name} PUBLIC ${CXX_FEATURES})
|
||||||
install(TARGETS ${example_name} RUNTIME DESTINATION bin/examples)
|
install(TARGETS ${example_name} RUNTIME DESTINATION bin/examples)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (TESTS)
|
||||||
file(GLOB TEST_SRC test*.cpp)
|
file(GLOB TEST_SRC test*.cpp)
|
||||||
source_group(tests FILES ${TEST_SRC})
|
source_group(tests FILES ${TEST_SRC})
|
||||||
|
|
||||||
|
@ -71,6 +79,7 @@ target_include_directories(tests PRIVATE ./Catch/include/)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
target_link_libraries(tests Threads::Threads ${LUA_LIBRARIES})
|
target_link_libraries(tests Threads::Threads ${LUA_LIBRARIES})
|
||||||
install(TARGETS tests RUNTIME DESTINATION bin)
|
install(TARGETS tests RUNTIME DESTINATION bin)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PythonInterp 3)
|
find_package(PythonInterp 3)
|
||||||
if (PYTHONINTERP_FOUND)
|
if (PYTHONINTERP_FOUND)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user