diff --git a/.travis.yml b/.travis.yml index 16d6b04e..5ee4e6c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -157,7 +157,11 @@ matrix: LLVM_VERSION=5.0.1 before_install: - brew update > /dev/null - - brew install zsh git ninja cmake python + - brew install zsh || true + - brew install git || true + - brew install cmake || true + - brew install python || true + - brew install ninja || true script: - ./scripts/run.osx.sh @@ -168,7 +172,11 @@ matrix: LLVM_VERSION=5.0.1 before_install: - brew update > /dev/null - - brew install zsh git ninja cmake python + - brew install zsh || true + - brew install git || true + - brew install cmake || true + - brew install python || true + - brew install ninja || true script: - ./scripts/run.osx.sh diff --git a/cmake/Modules/FindCatch.cmake b/cmake/Modules/FindCatch.cmake index 6af63a0c..4feb67ce 100644 --- a/cmake/Modules/FindCatch.cmake +++ b/cmake/Modules/FindCatch.cmake @@ -25,10 +25,10 @@ include(FindPackageHandleStandardArgs) include(Common/Core) # # Base variables -if (CATCH_VERSION) - set(catch_version ${CATCH_VERSION}) +if (Catch_FIND_VERSION) + set(catch_version ${Catch_FIND_VERSION}) else() - set(catch_version 2.0.1) + set(catch_version 2.1.2) endif() set(catch_lib catch_lib_${catch_version}) @@ -41,7 +41,7 @@ set(catch_include_dirs "${catch_build_toplevel}") set(catch_sources catch.hpp) prepend(catch_sources "${catch_build_toplevel}/" ${catch_sources}) -# # !! Catch 3.5 does not have DOWNLOAD_NO_EXTRACT e.e +# # !! CMake 3.5 does not have DOWNLOAD_NO_EXTRACT e.e # # Now I know why people don't like CMake that much: the earlier versions were kind of garbage # # External project to get sources #ExternalProject_Add(CATCH_BUILD_SOURCE diff --git a/cmake/Modules/FindLuaBuild.cmake b/cmake/Modules/FindLuaBuild.cmake index da1564b4..201163ca 100644 --- a/cmake/Modules/FindLuaBuild.cmake +++ b/cmake/Modules/FindLuaBuild.cmake @@ -99,9 +99,9 @@ endfunction(find_lua_build) if (LuaBuild_FIND_COMPONENTS) list(GET LuaBuild_FIND_COMPONENTS 0 LUA_VERSION) endif() -if (LuaBuild_VERSION) +if (LuaBuild_FIND_VERSION) if (LUA_VERSION) - set(LUA_VERSION "${LUA_VERSION}-${LuaBuild_VERSION}") + set(LUA_VERSION "${LUA_VERSION}-${LuaBuild_FIND_VERSION}") else() set(LUA_VERSION "${LuaBuild_VERSION}") endif() diff --git a/cmake/Modules/FindLuaBuild/LuaJIT.cmake b/cmake/Modules/FindLuaBuild/LuaJIT.cmake index b87d3a81..a31af9b6 100644 --- a/cmake/Modules/FindLuaBuild/LuaJIT.cmake +++ b/cmake/Modules/FindLuaBuild/LuaJIT.cmake @@ -165,14 +165,15 @@ if (MSVC) # Visual C++ is predicated off running msvcbuild.bat # which requires a Visual Studio Command Prompt if (BUILD_LUA_AS_DLL) - set(LUA_JIT_BUILD_COMMAND cd src && msvcbuild.bat) + set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND cd src && msvcbuild.bat) else() - set(LUA_JIT_BUILD_COMMAND cd src && msvcbuild.bat static) + set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND cd src && msvcbuild.bat static) endif() set(LUA_JIT_PREBUILT_LIB "lua51.lib") set(LUA_JIT_PREBUILT_IMP_LIB "lua51.lib") set(LUA_JIT_PREBUILT_DLL "lua51.dll") set(LUA_JIT_PREBUILT_EXP "lua51.exp") + set(LUA_JIT_PREBUILT_EXE "luajit.exe") else () # get the make command we need for this system find_program(MAKE_PROGRAM NAMES make mingw32-make mingw64-make) @@ -207,6 +208,8 @@ else () set(LUA_JIT_PREBUILT_DLL ${LUA_JIT_DLL_FILENAME}) set(LUA_JIT_PREBUILT_LIB ${LUA_JIT_LIB_FILENAME}) set(LUA_JIT_PREBUILT_IMP_LIB ${LUA_JIT_IMP_LIB_FILENAME}) + set(LUA_JIT_PREBUILT_EXE ${LUA_JIT_EXE_FILENAME}) + set(LUA_JIT_PREBUILT_EXP ${LUA_JIT_LIB_EXP_FILENAME}) if (WIN32) list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_SYS=Windows" "TARGET_SYS=Windows") @@ -218,19 +221,20 @@ else () set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND "${MAKE_PROGRAM}" ${LUA_JIT_MAKE_BUILD_MODIFICATIONS}) endif() -set(lualib luajitlib_${LUA_JIT_VERSION}) +set(lualib luajit_lib_${LUA_JIT_VERSION}) set(luainterpreter luajit_${LUA_JIT_VERSION}) -file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_LIB}" LUA_JIT_SOURCE_LUA_LIB) -file(TO_NATIVE_PATH "${LUA_JIT_LIB_FILE}" LUA_JIT_DESTINATION_LUA_LIB) -file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_IMP_LIB}" LUA_JIT_SOURCE_LUA_IMP_LIB) -file(TO_NATIVE_PATH "${LUA_JIT_IMP_LIB_FILE}" LUA_JIT_DESTINATION_LUA_IMP_LIB) -file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_DLL}" LUA_JIT_SOURCE_LUA_DLL) -file(TO_NATIVE_PATH "${LUA_JIT_DLL_FILE}" LUA_JIT_DESTINATION_LUA_DLL) -file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_EXP}" LUA_JIT_SOURCE_LUA_LIB_EXP) -file(TO_NATIVE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}" LUA_JIT_DESTINATION_LUA_LIB_EXP) -file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_EXE_FILENAME}" LUA_JIT_SOURCE_LUA_INTERPRETER) -file(TO_NATIVE_PATH "${LUA_JIT_EXE_FILE}" LUA_JIT_DESTINATION_LUA_INTERPRETER) +file(TO_CMAKE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_LIB}" LUA_JIT_SOURCE_LUA_LIB) +file(TO_CMAKE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_IMP_LIB}" LUA_JIT_SOURCE_LUA_IMP_LIB) +file(TO_CMAKE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_EXE}" LUA_JIT_SOURCE_LUA_INTERPRETER) +file(TO_CMAKE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_DLL}" LUA_JIT_SOURCE_LUA_DLL) +file(TO_CMAKE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_EXP}" LUA_JIT_SOURCE_LUA_LIB_EXP) + +file(TO_CMAKE_PATH "${LUA_JIT_DLL_FILE}" LUA_JIT_DESTINATION_LUA_DLL) +file(TO_CMAKE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}" LUA_JIT_DESTINATION_LUA_LIB_EXP) +file(TO_CMAKE_PATH "${LUA_JIT_IMP_LIB_FILE}" LUA_JIT_DESTINATION_LUA_IMP_LIB) +file(TO_CMAKE_PATH "${LUA_JIT_LIB_FILE}" LUA_JIT_DESTINATION_LUA_LIB) +file(TO_CMAKE_PATH "${LUA_JIT_EXE_FILE}" LUA_JIT_DESTINATION_LUA_INTERPRETER) if (WIN32 AND NOT MSVC) string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.0_LATEST_VERSION} lua_jit_same_version_20) @@ -244,7 +248,29 @@ elseif(LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest") endif() set(LUA_JIT_BYPRODUCTS "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_SOURCE_LUA_LIB_EXP}" - "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_SOURCE_LUA_IMP_LIB}") + "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_SOURCE_LUA_INTERPRETER}") + +set(LUA_JIT_INSTALL_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_LIB}" + "${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}") + +# # Post-Build moving steps for necessary items +# Add post-step to move library afterwards +set(LUA_JIT_POSTBUILD_COMMENTS "Executable - Moving \"${LUA_JIT_SOURCE_LUA_INTERPRETER}\" to \"${LUA_JIT_DESTINATION_LUA_INTERPRETER}\"...\n") +set(LUA_JIT_POSTBUILD_COMMANDS COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") +if (BUILD_LUA_AS_DLL) + if (MSVC) + set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS}Import Library - Moving \"${LUA_JIT_SOURCE_LUA_IMP_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_IMP_LIB}\"...\n") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}") + + set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS}Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB_EXP}\" to \"${LUA_JIT_DESTINATION_LUA_LIB_EXP}\"...\n") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} && "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}") + endif() + set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS}Dynamic Library - Moving \"${LUA_JIT_SOURCE_LUA_DLL}\" to \"${LUA_JIT_DESTINATION_LUA_DLL}\"...\n") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}") +else() + set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS}Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"...\n") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}") +endif() if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST) if (LUA_JIT_PULL_LATEST) @@ -255,8 +281,6 @@ if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST) ExternalProject_Add(LUA_JIT BUILD_IN_SOURCE TRUE BUILD_ALWAYS FALSE - # LuaJIT does not offer a TLS/SSL port - TLS_VERIFY FALSE PREFIX "${LUA_BUILD_TOPLEVEL}" SOURCE_DIR "${LUA_BUILD_TOPLEVEL}" DOWNLOAD_DIR "${LUA_BUILD_TOPLEVEL}" @@ -271,13 +295,13 @@ if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST) ${LUA_JIT_BUILD_COMMAND} INSTALL_COMMAND "" TEST_COMMAND "" - BUILD_BYPRODUCTS "${LUA_JIT_BYPRODUCTS}") + BUILD_BYPRODUCTS "${LUA_JIT_BYPRODUCTS}" "${LUA_JIT_INSTALL_BYPRODUCTS}") else() ExternalProject_Add(LUA_JIT BUILD_IN_SOURCE TRUE - BUILD_ALWAYS TRUE + BUILD_ALWAYS FALSE # LuaJIT does not offer a TLS/SSL port - # TLS_VERIFY TRUE + TLS_VERIFY FALSE PREFIX "${LUA_BUILD_TOPLEVEL}" SOURCE_DIR "${LUA_BUILD_TOPLEVEL}" DOWNLOAD_DIR "${LUA_BUILD_TOPLEVEL}" @@ -294,80 +318,34 @@ else() BUILD_BYPRODUCTS "${LUA_JIT_BYPRODUCTS}") endif() -# # Post-Build moving steps for necessary items -# Add post-step to move library afterwards - -set(LUA_JIT_EXTERNAL_PROJECT_DEPS "") -if (MSVC) - ExternalProject_Add_Step(LUA_JIT - postbuild.exp - DEPENDEES build - COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_LIB_EXP}\" to \"${LUA_JIT_DESTINATION_LUA_LIB_EXP}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}" - BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB_EXP}") - ExternalProject_Add_StepTargets(LUA_JIT postbuild_exp) - list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_exp") -endif() -if (BUILD_LUA_AS_DLL) - if (MSVC) - ExternalProject_Add_Step(LUA_JIT - postbuild_import_lib - DEPENDEES build - COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_IMP_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_IMP_LIB}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}" - BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_IMP_LIB}") - ExternalProject_Add_StepTargets(LUA_JIT postbuild_import_lib) - list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_import_lib") - endif() - ExternalProject_Add_Step(LUA_JIT - postbuild_dll - DEPENDEES build - COMMENT "Dynamic Library - Moving \"${LUA_JIT_SOURCE_LUA_DLL}\" to \"${LUA_JIT_DESTINATION_LUA_DLL}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}" - BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_DLL}") - ExternalProject_Add_StepTargets(LUA_JIT postbuild_dll) - list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_dll") -else() - ExternalProject_Add_Step(LUA_JIT - postbuild_lib - DEPENDEES build - COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}" - BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}") - ExternalProject_Add_StepTargets(LUA_JIT postbuild_lib) - list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_lib") -endif() - -ExternalProject_Add_Step(LUA_JIT - postbuild_exe - DEPENDEES build - COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_INTERPRETER}\" to \"${LUA_JIT_DESTINATION_LUA_INTERPRETER}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}" - BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") -ExternalProject_Add_StepTargets(LUA_JIT postbuild_exe) -list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_exe") - -# # TODO: +# # MAYBE?: # Add additional post-build step to move all necessary headers/lua files # for now, we just point directly to the `src` directory... +add_custom_command(TARGET LUA_JIT + POST_BUILD + ${LUA_JIT_POSTBUILD_COMMANDS} + BYPRODUCTS "${LUA_JIT_INSTALL_BYPRODUCTS}" +) + # # Lua Library add_library(${lualib} ${LUA_BUILD_LIBRARY_TYPE} IMPORTED) # make sure the library we export really does depend on Lua JIT's external project -add_dependencies(${lualib} LUA_JIT ${LUA_JIT_EXTERNAL_PROJECT_DEPS}) +add_dependencies(${lualib} LUA_JIT) +# Configure properties if (BUILD_LUA_AS_DLL) if (MSVC) set_target_properties(${lualib} PROPERTIES - IMPORTED_IMPLIB "${LUA_JIT_IMP_LIB_FILE}") + IMPORTED_IMPLIB "${LUA_JIT_DESTINATION_LUA_IMP_LIB}") endif() set_target_properties(${lualib} PROPERTIES - IMPORTED_LOCATION "${LUA_JIT_DLL_FILE}") + IMPORTED_LOCATION "${LUA_JIT_DESTINATION_LUA_DLL}") else () set_target_properties(${lualib} PROPERTIES - IMPORTED_LOCATION "${LUA_JIT_LIB_FILE}") + IMPORTED_LOCATION "${LUA_JIT_DESTINATION_LUA_LIB}") endif() set_target_properties(${lualib} PROPERTIES @@ -388,9 +366,10 @@ add_executable(${luainterpreter} IMPORTED) # Add location pointing to executable set_target_properties(${luainterpreter} PROPERTIES - IMPORTED_LOCATION "${LUA_JIT_EXE_FILE}") + IMPORTED_LOCATION "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") +add_dependencies(${luainterpreter} LUA_JIT) -# set externally-visible target indicator +# # set externally-visible target indicator set(LUA_LIBRARIES ${lualib}) set(LUA_INTERPRETER ${luainterpreter}) set(LUA_INCLUDE_DIRS "${LUA_JIT_SOURCE_DIR}") diff --git a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake index 0bf8c39c..d789801f 100644 --- a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake +++ b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake @@ -296,8 +296,8 @@ else() PRIVATE -w) endif() if (WIN32) - target_compile_definitions(${liblua} - PRIVATE LUA_USE_WINDOWS) + #target_compile_definitions(${liblua} + # PRIVATE LUA_USE_WINDOWS) else() target_compile_definitions(${liblua} PRIVATE LUA_USE_LINUX) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb6017f6..bd498bad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,7 +22,11 @@ # # # # sol2 tests -find_package(Catch 2.0.1 REQUIRED) +if (CMAKE_GENERATOR MATCHES "Visual Studio 14 2015") + find_package(Catch 1.1.12 REQUIRED) +else() + find_package(Catch 2.1.2 REQUIRED) +endif() file(GLOB SOL2_TEST_SOURCES test*.cpp) source_group(test_sources FILES ${SOL2_TEST_SOURCES})