summaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/mingw-w64.cmake8
-rw-r--r--cmake/opentrack-boilerplate.cmake82
-rw-r--r--cmake/opentrack-install.cmake15
-rw-r--r--cmake/opentrack-platform.cmake1
-rw-r--r--cmake/opentrack-version.cmake13
5 files changed, 94 insertions, 25 deletions
diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake
index a0dc4e7f..b1d6ff2a 100644
--- a/cmake/mingw-w64.cmake
+++ b/cmake/mingw-w64.cmake
@@ -16,7 +16,7 @@ unset(c)
unset(e)
# specify the cross compiler
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- set(p C:/msys64/mingw32/bin/)
+ set(p D:/cygwin64/opt/bin/)
set(e .exe)
endif()
#set(c ${p}i686-w64-mingw32-)
@@ -44,7 +44,7 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# oldest CPU supported here is Northwood-based Pentium 4. -sh 20150811
set(fpu "-ffast-math -mfpmath=both -mstackrealign -falign-functions=16 -falign-loops=16")
-set(cpu "-O3 -march=pentium4 -mtune=skylake -msse -msse2 -mno-sse3 -mno-avx -frename-registers")
+set(cpu "-O3 -march=pentium4 -mtune=corei7-avx -msse -msse2 -mno-sse3 -mno-avx -frename-registers")
set(lto "-fno-lto -fuse-linker-plugin -flto-compression-level=9 -flto-partition=balanced -fno-ipa-pta -fno-lto-odr-type-merging")
set(bloat "")
set(sections "-ffunction-sections -fdata-sections")
@@ -115,3 +115,7 @@ foreach(j "" _DEBUG _RELEASE)
set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${CMAKE_${i}_LINKER_FLAGS${j}}")
endforeach()
endforeach()
+
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE)
+endif() \ No newline at end of file
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index 3c5bd90a..ec1946f0 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -75,7 +75,7 @@ endfunction()
function(otr_compat target)
if(NOT MSVC)
- set_property(SOURCE ${${target}-moc} APPEND_STRING PROPERTY COMPILE_FLAGS " -w -Wno-error")
+ otr_prop(SOURCE ${${target}-moc} COMPILE_FLAGS "-w -Wno-error")
endif()
if(WIN32)
target_link_libraries(${target} dinput8 dxguid strmiids)
@@ -97,8 +97,8 @@ function(otr_compat target)
set(l-props "-Wl,--as-needed")
endif()
- set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${c-props} ${arg_COMPILE}")
- set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${l-props} ${arg_LINK}")
+ otr_prop(TARGET ${target} COMPILE_FLAGS "${c-props} ${arg_COMPILE}"
+ LINK_FLAGS "${l-props} ${arg_LINK}")
endfunction()
include(CMakeParseArguments)
@@ -110,17 +110,17 @@ function(otr_install_pdb_current_project target)
endfunction()
function(otr_i18n_for_target_directory n)
+ set(k "opentrack-${n}")
foreach(i ${opentrack-all-translations})
set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts")
add_custom_command(OUTPUT "${t}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang"
COMMAND "${Qt5_DIR}/../../../bin/lupdate" -silent -recursive -no-obsolete -locations relative . -ts "${t}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DEPENDS ${${n}-cc} ${${n}-hh} ${${n}-ui} ${${n}-rc}
+ DEPENDS ${${k}-cc} ${${k}-hh} ${${k}-ui} ${${k}-rc}
COMMENT "Running lupdate for ${n}/${i}")
set(target-name "i18n-lang-${i}-module-${n}")
add_custom_target(${target-name} DEPENDS "${t}")
- set_property(GLOBAL APPEND PROPERTY "opentrack-ts-targets-${i}" "${target-name}")
set_property(GLOBAL APPEND PROPERTY "opentrack-ts-files-${i}" "${t}")
endforeach()
endfunction()
@@ -208,3 +208,75 @@ function(otr_module n_)
set_property(GLOBAL APPEND PROPERTY opentrack-all-source-dirs "${CMAKE_CURRENT_SOURCE_DIR}")
endfunction()
+function(otr_prop type)
+ set(files "")
+ set(opts ${ARGN})
+ # only SOURCE allows for multiple files
+ if(".${type}" STREQUAL ".SOURCE")
+ while(TRUE)
+ # keep popping first element off `opts' and adding to `files`
+ list(LENGTH opts len)
+ if(NOT "${len}" GREATER 0)
+ break()
+ endif()
+ list(GET opts 0 k)
+ string(FIND "${k}" "." idx1)
+ string(FIND "${k}" "/" idx2)
+ if("${idx1}" GREATER -1 AND "${idx2}" GREATER -1)
+ list(REMOVE_AT opts 0)
+ list(APPEND files "${k}")
+ else()
+ # not a pathname
+ break()
+ endif()
+ endwhile()
+ # no files, break early
+ # happens a few in the codebase
+ list(LENGTH files len)
+ if(len EQUAL 0)
+ return()
+ endif()
+ else()
+ # single file argument
+ set(opts "${ARGN}")
+ list(GET opts 0 files)
+ list(REMOVE_AT opts 0)
+ endif()
+ # must pass some properties at least
+ list(LENGTH opts len)
+ if(NOT "${len}" GREATER 0)
+ message(FATAL_ERROR "no properties given")
+ endif()
+
+ # prop name but no value
+ list(LENGTH opts len)
+ math(EXPR mod "${len} % 2")
+ if(NOT "${mod}" EQUAL 0)
+ message(FATAL_ERROR "must specify parameter for each property")
+ endif()
+
+ foreach(f ${files})
+ set(opts-copy "${opts}")
+
+ while(TRUE)
+ list(LENGTH opts-copy len)
+ if ("${len}" LESS 2)
+ break()
+ endif()
+
+ # pop off two elements, set property
+ list(GET opts-copy 0 name)
+ list(GET opts-copy 1 value)
+ list(REMOVE_AT opts-copy 1 0)
+
+ get_property(old "${type}" "${f}" PROPERTY "${name}")
+ if(".${old}" STREQUAL ".")
+ set(spc "")
+ else()
+ set(spc " ")
+ endif()
+
+ set_property("${type}" "${f}" APPEND_STRING PROPERTY "${name}" "${spc}${value}")
+ endwhile()
+ endforeach()
+endfunction()
diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake
index e0d73d5f..2f91ab55 100644
--- a/cmake/opentrack-install.cmake
+++ b/cmake/opentrack-install.cmake
@@ -50,12 +50,10 @@ otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/AUTHORS.md")
function(merge_translations)
install(CODE "file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/i18n\")")
- set(all-ts-files "")
set(all-qm-files "")
foreach(i ${opentrack-all-translations})
get_property(ts-files GLOBAL PROPERTY "opentrack-ts-files-${i}")
- #get_property(ts-deps GLOBAL PROPERTY "opentrack-ts-targets-${i}")
set(ts-files_ "")
@@ -67,25 +65,20 @@ function(merge_translations)
set(ts-files "${ts-files_}")
- foreach(k ${ts-files})
- list(APPEND all-ts-files "${k}")
- endforeach()
-
if(NOT ".${ts-files}" STREQUAL ".")
- set(lrelease-deps "${ts-files}")
-
set(qm-output "${CMAKE_CURRENT_BINARY_DIR}/${i}.qm")
list(APPEND all-qm-files "${qm-output}")
add_custom_command(OUTPUT "${qm-output}"
COMMAND "${Qt5_DIR}/../../../bin/lrelease" -nounfinished -silent ${ts-files} -qm "${qm-output}"
- DEPENDS ${lrelease-deps}
- COMMENT "Running lrelease for ${i}")
+ DEPENDS ${ts-files}
+ COMMENT "Running lrelease for ${i}"
+ )
set(lang-target "i18n-lang-${i}")
+ add_custom_target("${lang-target}" DEPENDS "${qm-output}")
install(FILES "${qm-output}" DESTINATION "${opentrack-i18n-pfx}" RENAME "${i}.qm" ${opentrack-perms})
endif()
endforeach()
add_custom_target(i18n ALL DEPENDS ${all-qm-files})
- add_custom_target(force-i18n DEPENDS ${all-ts-files} ${all-qm-files} i18n)
endfunction()
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
index 3e0319ac..27d38d88 100644
--- a/cmake/opentrack-platform.cmake
+++ b/cmake/opentrack-platform.cmake
@@ -49,7 +49,6 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zi")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Zi")
endif()
- #set(CMAKE_C_FLAGS " -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}")
foreach (i SHARED MODULE EXE)
set(CMAKE_${i}_LINKER_FLAGS "${CMAKE_${i}_LINKER_FLAGS} -DYNAMICBASE -NXCOMPAT")
diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake
index 00a5df1d..181fc613 100644
--- a/cmake/opentrack-version.cmake
+++ b/cmake/opentrack-version.cmake
@@ -29,17 +29,18 @@ const char* opentrack_version;
const char* opentrack_version = \"${OPENTRACK_COMMIT}${_build_type}\";
")
+set(file "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
set(crapola-ver)
-if(EXISTS ${CMAKE_BINARY_DIR}/version.c)
- file(READ ${CMAKE_BINARY_DIR}/version.c crapola-ver)
+if(EXISTS "${file}")
+ file(READ "${file}" crapola-ver)
endif()
if(NOT (crapola-ver STREQUAL version-string))
- file(WRITE ${CMAKE_BINARY_DIR}/version.c "${version-string}")
+ file(WRITE "${file}" "${version-string}")
endif()
-add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.c)
+add_library(opentrack-version STATIC "${file}")
+
if(NOT MSVC)
- set_property(TARGET opentrack-version APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto")
+ otr_prop(TARGET opentrack-version COMPILE_FLAGS "-fno-lto")
endif()
-otr_compat(opentrack-version)