diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-04 09:19:39 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-04 09:29:28 +0200 |
commit | f58efb5c2c51e5866d4640036865792b822641f6 (patch) | |
tree | 4316d898c27c3adb1c332544876445ba73bd1eb0 /CMakeLists.txt | |
parent | 27bbb01ff3d49bd37daa9649f5c2320663c46aa4 (diff) | |
parent | 0bf534ff329cabaa61a0dddb8671827577407aba (diff) |
Merge branch 'unstable' into trackhat-ui
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1571556a..601f935d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,15 @@ find_package(Qt5 COMPONENTS SerialPort QUIET) include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) +if(MSVC) + add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) +endif() + set(my-qt-deps) if(WIN32) # hack to avoid breakage on buildbot set(my-qt-deps ws2_32) endif() -set(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${my-qt-deps}) # note, hatire supports both ftnoir and opentrack # don't remove without being sure as hell -sh 20140922 @@ -65,12 +69,17 @@ if(CMAKE_COMPILER_IS_GNUCXX OR APPLE) set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS} ") endif() +set_property(GLOBAL PROPERTY USE_FOLDERS OFF) + # qt broken as usual set(EXTRA-MOCS opentrack/options.hpp) macro(opentrack_module n dir) file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp ${EXTRA-MOCS}) file(GLOB ${n}-res ${dir}/*.rc) + foreach(f ${n}-res) + set_source_files_properties(${f} PROPERTIES LANGUAGE RC) + endforeach() file(GLOB ${n}-ui ${dir}/*.ui) file(GLOB ${n}-rc ${dir}/*.qrc) endmacro() @@ -82,6 +91,13 @@ macro(opentrack_qt n) set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res}) endmacro() +set(msvc-subsystem "/VERSION:5.1 /SUBSYSTEM:WINDOWS,5.01") +function(opentrack_compat target) + if(MSVC) + set_target_properties(${target} PROPERTIES LINK_FLAGS "${msvc-subsystem} /DEBUG /OPT:ICF") + endif() +endfunction() + macro(opentrack_library n dir) cmake_parse_arguments(foolib "" "LINK;COMPILE;GNU-LINK;GNU-COMPILE;STATIC" "" ${ARGN}) if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") @@ -105,7 +121,11 @@ macro(opentrack_library n dir) COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} ${visibility}" ) else() - set_target_properties(${n} PROPERTIES LINK_FLAGS ${foolib_LINK} COMPILE_FLAGS ${foolib_COMPILE}) + set(link-flags) + if(MSVC) + set(link-flags "${msvc-subsystem} /DEBUG /OPT:ICF") + endif() + set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") endif() if (NOT foolib_STATIC) install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) @@ -174,6 +194,7 @@ add_custom_target(tarball DEPENDS ${filename}) opentrack_module(opentrack-api opentrack) opentrack_qt(opentrack-api) add_library(opentrack-api STATIC ${opentrack-api-all}) +opentrack_compat(opentrack-api) target_link_libraries(opentrack-api ${MY_QT_LIBS}) if(NOT WIN32) @@ -209,13 +230,13 @@ if(SDK_XPLANE) SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" - COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM210" + COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM200 -DXPLM210" LIBRARY_OUTPUT_NAME "opentrack.xpl" PREFIX "" SUFFIX "") endif() if(APPLE) SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES - COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM210 -framework XPLM -framework XPWidgets" + COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets" LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") endif() if(UNIX AND NOT APPLE) @@ -224,31 +245,36 @@ if(SDK_XPLANE) endif() add_library(opentrack-compat STATIC ${opentrack-compat-c}) +opentrack_compat(opentrack-compat) # uh... if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() opentrack_module(opentrack-csv csv) add_library(opentrack-csv STATIC ${opentrack-csv-c}) +opentrack_compat(opentrack-csv) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) opentrack_module(opentrack-pose-widget pose-widget) opentrack_qt(opentrack-pose-widget) add_library(opentrack-pose-widget STATIC ${opentrack-pose-widget-all}) +opentrack_compat(opentrack-pose-widget) target_include_directories(opentrack-pose-widget PUBLIC pose-widget/) # else Qt moc breaks target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) opentrack_module(opentrack-spline-widget qfunctionconfigurator) opentrack_qt(opentrack-spline-widget) add_library(opentrack-spline-widget STATIC ${opentrack-spline-widget-all}) +opentrack_compat(opentrack-spline-widget) target_include_directories(opentrack-spline-widget PUBLIC qfunctionconfigurator/) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-version STATIC opentrack/version.C) +add_library(opentrack-version STATIC opentrack/version.cc) +opentrack_compat(opentrack-version) set_target_properties(opentrack-version PROPERTIES COMPILE_DEFINITIONS - "IN_VERSION_UNIT;OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") + "OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") opentrack_library(opentrack-filter-accela ftnoir_filter_accela STATIC TRUE) target_link_libraries(opentrack-filter-accela opentrack-spline-widget) @@ -258,7 +284,12 @@ opentrack_library(opentrack-proto-fgfs ftnoir_protocol_fg) if(SDK_VJOY) opentrack_library(opentrack-proto-vjoy ftnoir_protocol_vjoy GNU-LINK "-Wl,--enable-stdcall-fixup") - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} ${SDK_VJOY}/VJoy.dll) + if(MSVC) + set(ext .lib) + else() + set(ext .dll) + endif() + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} ${SDK_VJOY}/VJoy${ext}) target_include_directories(opentrack-proto-vjoy SYSTEM PUBLIC ${SDK_VJOY}) endif() @@ -274,6 +305,9 @@ if(SDK_FSUIPC) opentrack_library(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) + if(MSVC) + set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBC.lib") + endif() #target_link_directories(${SDK_FSUIPC}) endif() @@ -358,12 +392,21 @@ if(SDK_RIFT AND FALSE) set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") set(c-flags "-fno-strict-aliasing") else() - set(c-flags "-fno-strict-aliasing") + if(NOT MSVC) + set(c-flags "-fno-strict-aliasing") + endif() endif() opentrack_library(opentrack-tracker-rift ftnoir_tracker_rift LINK ${link-flags} COMPILE ${c-flags}) target_include_directories(opentrack-tracker-rift SYSTEM PUBLIC ${SDK_RIFT}/Include ${SDK_RIFT}/Src) if(WIN32) - target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/libLibOVR.a winmm setupapi ws2_32 imagehlp wbemuuid) + if(MSVC) + set(ext lib) + set(p) + else() + set(ext a) + set(p lib) + endif() + target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/${p}LibOVR.${ext} winmm setupapi ws2_32 imagehlp wbemuuid) else() if(NOT APPLE) target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/libLibOVR.a udev Xinerama) @@ -377,9 +420,16 @@ if(SDK_HYDRA AND FALSE) opentrack_library(opentrack-tracker-hydra ftnoir_tracker_hydra) target_include_directories(opentrack-tracker-hydra SYSTEM PUBLIC ${SDK_HYDRA}/include ${SDK_HYDRA}/include/sixense_utils) if(WIN32) + if(MSVC) + set(dir lib) + set(ext lib) + else() + set(dir bin) + set(ext dll) + endif() target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" - #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" + "${SDK_HYDRA}/${dir}/win32/release_dll/sixense.${ext}" + #"${SDK_HYDRA}/${dir}/win32/release_dll/sixense_utils.${ext}" ) install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" @@ -442,7 +492,7 @@ endif() opentrack_qt(opentrack) add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) target_link_libraries(opentrack opentrack-filter-accela opentrack-tracker-pt) - +opentrack_compat(opentrack) if(NOT WIN32) set_target_properties(opentrack PROPERTIES SUFFIX ".bin") endif() |