these cmake details are starting to get unruly...

This commit is contained in:
ThePhD 2018-02-11 00:53:53 -05:00
parent 7056156273
commit 6f80e271d7
8 changed files with 54 additions and 33 deletions

View File

@ -63,10 +63,10 @@ if (MSVC)
endif()
else()
if (PLATFORM MATCHES "x86")
list(APPEND CMAKE_C_FLAGS "-m32")
list(APPEND CMAKE_CXX_FLAGS "-m32")
list(APPEND CMAKE_EXE_LINKER_FLAGS "-m32")
list(APPEND CMAKE_SHARED_LINKER_FLAGS "-m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif()
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
endif()
@ -110,6 +110,7 @@ set(PLATFORM "x64" CACHE STRING "Target platform to compile for when building bi
option(CI "Enable build of tests" OFF)
option(TESTS "Enable build of tests" OFF)
option(EXAMPLES "Enable build of examples" OFF)
option(INTEROP_EXAMPLES "Enable build of interop examples" OFF)
option(SINGLE "Enable build of single header files" ON)
option(DOCS "Enable build of documentation" OFF)
# Single tests and examples tests will only be turned on if both SINGLE and TESTS are defined
@ -117,8 +118,12 @@ CMAKE_DEPENDENT_OPTION(TESTS_SINGLE "Enable build of tests using the generated s
"SINGLE;TESTS" OFF)
CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF
"SINGLE;EXAMPLES" OFF)
CMAKE_DEPENDENT_OPTION(INTEROP_EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF
"SINGLE;INTEROP_EXAMPLES" OFF)
CMAKE_DEPENDENT_OPTION(TESTS_EXAMPLES "Enable build of examples as tests" ON
"EXAMPLES" OFF)
CMAKE_DEPENDENT_OPTION(TESTS_INTEROP_EXAMPLES "Enable build of interop examples as tests" ON
"EXAMPLES;INTEROP_EXAMPLES" OFF)
# # # sol2 Library
@ -204,14 +209,14 @@ if (CI)
endif()
# # # Tests, Examples and other CI suites that come with sol2
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE OR INTEROP_EXAMPLES)
# # # Libraries
# Here, we pull in all the necessary libraries for building examples and tests
# Find threading library
if (NOT MSVC)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
#set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads)
find_package(Threads REQUIRED)
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
@ -238,7 +243,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
endif()
# # Enable test harness for regular, example or single tests
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES)
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES)
# enable ctest
message(STATUS "sol2 testing enabled")
enable_testing()
@ -246,7 +251,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
# # # Examples
# # Enable examples to be built against the library
if (EXAMPLES OR TESTS_EXAMPLES OR EXAMPLES_SINGLE)
if (EXAMPLES OR TESTS_EXAMPLES OR EXAMPLES_SINGLE OR INTEROP_EXAMPLES OR INTEROP_EXAMPLES_SINGLE OR TEST_INTEROP_EXAMPLES)
# NOTE: will also add to tests if TESTS is defined
message(STATUS "sol2 adding examples...")
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")

View File

@ -186,13 +186,15 @@ else ()
# make sure to apply -pagezero_size 10000 -image_base 100000000 (done later for XCode Targets)
set(LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_T=${LUA_JIT_EXE_FILENAME}")
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_A=${LUA_JIT_LIB_FILENAME}")
set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "CFLAGS= ")
set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "")
set(LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS "")
set(LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS "")
if (BUILD_LUA_AS_DLL)
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_SO=${LUA_JIT_DLL_FILENAME}" "TARGET_SONAME=${LUA_JIT_DLL_FILENAME}" "TARGET_DYLIBNAME=${LUA_JIT_DLL_FILENAME}" "TARGET_DLLNAME=${LUA_JIT_DLL_FILENAME}")
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "BUILDMODE=dynamic")
else()
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "BUILDMODE=static")
set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}-fPIC ")
set(LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS} -fPIC")
endif()
set(LUA_JIT_PREBUILT_DLL ${LUA_JIT_DLL_FILENAME})
@ -203,10 +205,13 @@ else ()
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_SYS=Windows" "TARGET_SYS=Windows")
endif()
if (PLATFORM MATCHES "x86")
set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}-m32 ")
set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS} -m32")
set(LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS} -m32")
endif()
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS ${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS})
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "CFLAGS=${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}")
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "TARGET_CFLAGS=${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS}")
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_CFLAGS=${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}")
set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND "${MAKE_PROGRAM}" ${LUA_JIT_MAKE_BUILD_MODIFICATIONS})
endif()

View File

@ -26,11 +26,13 @@
# just add the subdirectory
add_subdirectory(require_dll_example)
# # interop examples
add_subdirectory(interop/kaguya)
add_subdirectory(interop/tolua)
add_subdirectory(interop/LuaBridge)
add_subdirectory(interop/luwra)
if (INTEROP_EXAMPLES)
# # interop examples
add_subdirectory(interop/kaguya)
add_subdirectory(interop/tolua)
add_subdirectory(interop/LuaBridge)
add_subdirectory(interop/luwra)
endif(INTEROP_EXAMPLES)
# # single-source compilable examples
@ -86,12 +88,14 @@ function (MAKE_EXAMPLE example_source_file is_single)
install(TARGETS ${example_name} RUNTIME DESTINATION bin)
endfunction(MAKE_EXAMPLE)
foreach(example_source_file ${EXAMPLES_SRC})
MAKE_EXAMPLE(${example_source_file} FALSE)
endforeach()
if (SOL2_SINGLE_FOUND AND EXAMPLES_SINGLE)
if (EXAMPLES)
foreach(example_source_file ${EXAMPLES_SRC})
MAKE_EXAMPLE(${example_source_file} TRUE)
MAKE_EXAMPLE(${example_source_file} FALSE)
endforeach()
endif()
if (SOL2_SINGLE_FOUND AND EXAMPLES_SINGLE)
foreach(example_source_file ${EXAMPLES_SRC})
MAKE_EXAMPLE(${example_source_file} TRUE)
endforeach()
endif()
endif()

View File

@ -40,6 +40,6 @@ function (make_luabridge_interop_example target_library is_single)
endfunction()
make_luabridge_interop_example(sol2 FALSE)
if (TESTS_SINGLE)
if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE)
make_luabridge_interop_example(sol2_single TRUE)
endif()

View File

@ -34,12 +34,12 @@ function (make_kaguya_interop_example target_library is_single)
if (NOT MSVC)
target_compile_options(${example_name} PRIVATE -Wno-noexcept-type)
endif()
if (TESTS_EXAMPLES)
if (TESTS_INTEROP_EXAMPLES)
add_test(NAME ${example_name} COMMAND ${example_name})
endif()
endfunction()
make_kaguya_interop_example(sol2 FALSE)
if (TESTS_SINGLE)
if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE)
make_kaguya_interop_example(sol2_single TRUE)
endif()

View File

@ -40,6 +40,6 @@ function (make_luwra_interop_example target_library is_single)
endfunction()
make_luwra_interop_example(sol2 FALSE)
if (TESTS_SINGLE)
if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE)
make_luwra_interop_example(sol2_single TRUE)
endif()

View File

@ -40,6 +40,6 @@ function(make_tolua_interop_example target_library is_single)
endfunction()
make_tolua_interop_example(sol2 FALSE)
if (TESTS_SINGLE)
if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE)
make_tolua_interop_example(sol2_single TRUE)
endif()

View File

@ -50,6 +50,13 @@ echo -en "travis_fold:start:build_preparation.1\r"
source ./sol2.compiler.vars
fi
if [ ${LUA_VERSION} =~ '5.3' ]
then
export INTEROP_DEFINES=-DINTEROP_EXAMPLES=ON -DTESTS_INTEROP_EXAMPLES=ON -DINTEROP_EXAMPLES_SINGLE=ON
else
export INTEROP_DEFINES=
fi
mkdir -p Debug Release
export build_type_cc=-DCMAKE_C_COMPILER\=${CC}
@ -70,7 +77,7 @@ echo -en "travis_fold:end:build_preparation.2\r"
echo -en "travis_fold:start:build.debug\r"
cd Debug
cmake ${SOL2_DIR} -G Ninja -DCMAKE_BUILD_TYPE=Debug ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON
cmake ${SOL2_DIR} -G Ninja -DCMAKE_BUILD_TYPE=Debug ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON ${INTEROP_DEFINES}
cmake --build . --config Debug
echo -en "travis_fold:end:build.debug\r"
echo -en "travis_fold:start:test.debug\r"
@ -80,7 +87,7 @@ echo -en "travis_fold:end:test.debug\r"
echo "travis_fold:start:build.release\r"
cd Release
cmake ${SOL2_DIR} -G Ninja -DCMAKE_BUILD_TYPE=Release ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON
cmake ${SOL2_DIR} -G Ninja -DCMAKE_BUILD_TYPE=Release ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON ${INTEROP_DEFINES}
cmake --build . --config Release
echo -en "travis_fold:end:build.release\r"
echo -en "travis_fold:start:test.release\r"