diff options
-rw-r--r-- | cmake/mingw-w64.cmake | 2 | ||||
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 93 | ||||
-rw-r--r-- | cmake/opentrack-qt.cmake | 41 | ||||
-rw-r--r-- | compat/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compat/nan.cpp | 18 | ||||
-rw-r--r-- | dinput/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sdk-paths-sthalik@MSVC.cmake | 6 |
7 files changed, 84 insertions, 80 deletions
diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake index a79a913b..3aeafa69 100644 --- a/cmake/mingw-w64.cmake +++ b/cmake/mingw-w64.cmake @@ -9,7 +9,7 @@ SET(CMAKE_SYSTEM_VERSION 5) # specify the cross compiler if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") #set(p D:/cygwin64/opt/bin/) - set(p "C:/msys64/mingw32/bin/") + set(p "/mingw32/bin/") set(e .exe) set(c "${p}") else() diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index e4369452..a8da8a23 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -28,7 +28,8 @@ endif() function(otr_glob_sources var) set(dir "${CMAKE_CURRENT_SOURCE_DIR}") - file(GLOB ${var}-cc ${dir}/*.cpp ${dir}/*.c) + file(GLOB ${var}-cxx ${dir}/*.cpp) + file(GLOB ${var}-cc ${dir}/*.c) file(GLOB ${var}-hh ${dir}/*.h ${dir}/*.hpp) file(GLOB ${var}-res ${dir}/*.rc) foreach(f ${var}-res) @@ -36,36 +37,22 @@ function(otr_glob_sources var) endforeach() file(GLOB ${var}-ui ${dir}/*.ui) file(GLOB ${var}-rc ${dir}/*.qrc) - set(${var}-all ${${var}-cc} ${${var}-hh} ${${var}-rc} ${${var}-res}) + set(${var}-all ${${var}-cc} ${${var}-cxx} ${${var}-hh} ${${var}-rc} ${${var}-res}) foreach(i ui rc res cc hh all) set(${var}-${i} "${${var}-${i}}" PARENT_SCOPE) endforeach() endfunction() -function(otr_qt n) - if(".${${n}-hh}" STREQUAL ".") - message(FATAL_ERROR "project ${n} not globbed") - endif() - qt5_wrap_cpp(${n}-moc ${${n}-hh} OPTIONS --no-notes) - qt5_wrap_ui(${n}-uih ${${n}-ui}) - qt5_add_resources(${n}-rcc ${${n}-rc}) - - foreach(i moc uih rcc) - set(${n}-${i} "${${n}-${i}}" PARENT_SCOPE) - list(APPEND ${n}-all ${${n}-${i}}) - endforeach() - set(${n}-all "${${n}-all}" PARENT_SCOPE) -endfunction() - function(otr_fixup_subsystem n) + otr_find_msvc_editbin(editbin-pathname) if(MSVC) set(subsystem WINDOWS) get_property(type TARGET "${n}" PROPERTY TYPE) - set(loc "$<TARGET_FILE:${n}>") if (NOT type STREQUAL "STATIC_LIBRARY") + set(loc "$<TARGET_FILE:${n}>") add_custom_command(TARGET "${n}" POST_BUILD - COMMAND editbin -nologo -SUBSYSTEM:${subsystem},5.01 -OSVERSION:5.1 \"${loc}\") + COMMAND "${editbin-pathname}" -nologo -SUBSYSTEM:${subsystem},5.01 -OSVERSION:5.1 \"${loc}\") endif() endif() endfunction() @@ -74,33 +61,55 @@ function(otr_compat target) if(NOT MSVC) otr_prop(SOURCE ${${target}-moc} COMPILE_FLAGS "-w -Wno-error") endif() - if(WIN32) - target_link_libraries(${target} dinput8 dxguid strmiids) - endif() - otr_fixup_subsystem(${target}) - set(c-props) - set(l-props) - get_property(linker-lang TARGET ${target} PROPERTY LINKER_LANGUAGE) + get_property(type TARGET "${n}" PROPERTY TYPE) + if (".${TYPE}" STREQUAL ".EXECUTABLE") + otr_fixup_subsystem(${target}) + endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT MSVC) - set(c-props " -fvisibility=hidden") - if(NOT is-c-only) - if(NOT WIN32 OR NOT ".${CMAKE_CXX_COMPILER_ID}" STREQUAL ".Clang") - set(c-props "${c-props} -fuse-cxa-atexit") - endif() + otr_prop(TARGET ${target} COMPILE_FLAGS "-fvisibility=hidden") + + # gives incorrect result + #get_property(linker-lang TARGET ${target} PROPERTY LINKER_LANGUAGE) + + if (NOT ".${${target}-cxx}" STREQUAL ".") # not a C only target + otr_prop(TARGET ${target} COMPILE_FLAGS "-fuse-cxa-atexit") endif() - endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT MSVC) - set(l-props "-Wl,--as-needed") + if(NOT APPLE) + otr_prop(TARGET ${target} LINK_FLAGS "-Wl,--as-needed") + endif() endif() +endfunction() - otr_prop(TARGET ${target} COMPIcLE_FLAGS "${c-props} ${arg_COMPILE}" - LINK_FLAGS "${l-props} ${arg_LINK}") +function(otr_is_sln_generator var) + string(FIND "${CMAKE_GENERATOR}" "Visual Studio " is-msvc) + if(is-msvc EQUAL 0) + set(${var} TRUE PARENT_SCOPE) + else() + set(${var} FALSE PARENT_SCOPE) + endif() endfunction() -include(CMakeParseArguments) +function(otr_find_msvc_editbin varname) + if(MSVC) + # on .sln generator we have no editbin in path + is_sln_generator(is-msvc) + if(is-msvc) + # this is bad but what can we do? searching for vcvarsall.bat + # would be easier, but then we'd have to differentiate x86/amd64 + # cross tools, etc. which is a can of worms and if/else branches. + get_filename_component(linker-dir "${CMAKE_LINKER}" DIRECTORY) + find_file(opentrack_editbin-executable "editbin.exe" "${linker-dir}" "${linker-dir}/.." "${linker-dir}/../..") + otr_escape_string("${editbin-executable}" editbin-executable) + else() + set(opentrack_editbin-executable "editbin") + endif() + mark_as_advanced(FORCE opentrack_editbin-executable) + set("${varname}" "${opentrack_editbin-executable}" PARENT_SCOPE) + endif() +endfunction() function(otr_install_pdb_current_project target) if(MSVC) @@ -108,6 +117,8 @@ function(otr_install_pdb_current_project target) endif() endfunction() +include(CMakeParseArguments) + function(otr_module n_) message(STATUS "module ${n_}") cmake_parse_arguments(arg @@ -182,9 +193,11 @@ function(otr_module n_) else() install(TARGETS "${n}" ${opentrack-hier-str} PERMISSIONS ${opentrack-perms-exec}) endif() - set(opentrack_install-debug-info FALSE CACHE BOOL "Whether to build and install debug info at install time") - if(opentrack_install-debug-info) - otr_install_pdb_current_project(${n}) + if(MSVC) + set(opentrack_install-debug-info FALSE CACHE BOOL "Whether to build and install debug info at install time") + if(opentrack_install-debug-info) + otr_install_pdb_current_project(${n}) + endif() endif() endif() diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake index f297f482..bb0ea4a3 100644 --- a/cmake/opentrack-qt.cmake +++ b/cmake/opentrack-qt.cmake @@ -15,7 +15,7 @@ if(WIN32) message(FATAL_ERROR "${i} ${path}") endif() install(FILES "${path}" DESTINATION .) - if(NOT MSVC AND opentrack_install-debug-info AND EXISTS "${path}.pdb") + if(MSVC AND opentrack_install-debug-info AND EXISTS "${path}.pdb") install(FILES "${path}.pdb" DESTINATION "${opentrack-hier-debug}") endif() endforeach() @@ -24,32 +24,17 @@ if(WIN32) install(FILES "${qwindows-dll}" DESTINATION "./platforms") endif() -function(is_msvc_sln_generator var) - string(FIND "${CMAKE_GENERATOR}" "Visual Studio " is-msvc) - if(is-msvc EQUAL 0) - set(${var} TRUE PARENT_SCOPE) - else() - set(${var} FALSE PARENT_SCOPE) - endif() -endfunction() - -if(MSVC AND FALSE) - # on .sln generator we have no editbin in path - is_msvc_sln_generator(is-msvc) - if(is-msvc) - # this is bad but what can we do? searching for vcvarsall.bat - # would be easier, but then we'd have to differentiate x86/amd64 - # cross tools, etc. which is a can of worms and if/else branches. - get_filename_component(linker-dir "${CMAKE_LINKER}" DIRECTORY) - find_file(editbin-executable-filepath "editbin.exe" "${linker-dir}" "${linker-dir}/.." "${linker-dir}/../..") - otr_escape_string("${editbin-executable-filepath}" editbin-executable) - else() - set(editbin-executable "editbin") +function(otr_qt n) + if(".${${n}-hh}" STREQUAL ".") + message(FATAL_ERROR "project ${n} not globbed") endif() + qt5_wrap_cpp(${n}-moc ${${n}-hh} OPTIONS --no-notes) + qt5_wrap_ui(${n}-uih ${${n}-ui}) + qt5_add_resources(${n}-rcc ${${n}-rc}) - install(CODE " - foreach(i Qt5Core Qt5Gui Qt5Network Qt5SerialPort Qt5Widgets platforms/qwindows) - execute_process(COMMAND \"${editbin-executable}\" -nologo -SUBSYSTEM:WINDOWS,5.01 -OSVERSION:5.1 \"\${i}.dll\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}\") - endforeach() - ") -endif() + foreach(i moc uih rcc) + set(${n}-${i} "${${n}-${i}}" PARENT_SCOPE) + list(APPEND ${n}-all ${${n}-${i}}) + endforeach() + set(${n}-all "${${n}-all}" PARENT_SCOPE) +endfunction() diff --git a/compat/CMakeLists.txt b/compat/CMakeLists.txt index 7e5dd4cd..d55c38c6 100644 --- a/compat/CMakeLists.txt +++ b/compat/CMakeLists.txt @@ -5,7 +5,7 @@ if(NOT WIN32 AND NOT APPLE) endif() if(WIN32) - target_link_libraries(opentrack-compat winmm) + target_link_libraries(opentrack-compat winmm strmiids) endif() if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/compat/nan.cpp b/compat/nan.cpp index 338fb789..037efbe1 100644 --- a/compat/nan.cpp +++ b/compat/nan.cpp @@ -1,14 +1,16 @@ #include "export.hpp" +#include "compat/macros.hpp" + #if defined(_MSC_VER) -# include <cmath> -# define my_isnan std::isnan -# define my_isinf std::isinf -OTR_COMPAT_EXPORT __declspec(noinline) bool nanp(double x) +# include <float.h> +# include <math.h> +# define my_isnan ::_isnan +# define my_isinf ::isinf #elif defined __MINGW32__ -int __cdecl my_isnan(double)__asm__("__isnan"); -int __cdecl my_fpclassify(double)__asm__("___fpclassify"); +static int __cdecl my_isnan(double)__asm__("__isnan"); +static int __cdecl my_fpclassify(double)__asm__("___fpclassify"); #define FP_NAN 0x0100 #define FP_NORMAL 0x0400 @@ -18,18 +20,16 @@ int __cdecl my_fpclassify(double)__asm__("___fpclassify"); #define my_isinf(x) (my_fpclassify(x) == FP_INFINITE) -OTR_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double x) #elif defined __APPLE__ # include <math.h> # define my_isnan(x) isnan(x) # define my_isinf(x) isinf(x) -OTR_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double x) #else int my_isnan(double)__asm__("isnan"); int my_isinf(double)__asm__("isinf"); -OTR_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double x) #endif +OTR_COMPAT_EXPORT never_inline bool nanp(double x) { return my_isnan(x) || my_isinf(x); } diff --git a/dinput/CMakeLists.txt b/dinput/CMakeLists.txt index c6962fcd..865c92cb 100644 --- a/dinput/CMakeLists.txt +++ b/dinput/CMakeLists.txt @@ -1,4 +1,4 @@ if(WIN32) otr_module(dinput BIN) - target_link_libraries(opentrack-dinput dinput8) + target_link_libraries(opentrack-dinput dinput8 dxguid) endif() diff --git a/sdk-paths-sthalik@MSVC.cmake b/sdk-paths-sthalik@MSVC.cmake index 1ecf1da5..df7a6138 100644 --- a/sdk-paths-sthalik@MSVC.cmake +++ b/sdk-paths-sthalik@MSVC.cmake @@ -1,3 +1,9 @@ +# qtbase configure line for safekeeping
+# "../configure" -prefix d:\dev\qt-5.10.0 -no-ico -no-gif -no-libjpeg -opengl desktop -no-angle -no-fontconfig -no-harfbuzz -nomake tests -no-mp -release -opensource -shared -confirm-license -no-freetype -force-debug-info -separate-debug-info -make-tool jom -platform win32-msvc
+
+# remember to change -MD to -MT in mkspecs/
+# also add CFLAGS -Zi and LFLAGS -DEBUG
+
set(Qt5_DIR "D:/dev/qt-5.10.0/lib/cmake/Qt5")
set(__depdir "d:/dev/opentrack-depends/")
set(OpenCV_DIR "${__depdir}/opencv/build-msvc15")
|