summaryrefslogblamecommitdiffstats
path: root/CMakeLists.txt
blob: 599979cec9166e3cd5be54642567cef48e0729a6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                                                  









                                                                                  






                                                                           
                                               



                                                 



                                 

 
     
 
                                                                   
 
                                                    




                                                                                               
                                                                                                      

                                                 
                                                         














                                                                                           
                                                                





                         





                                

              
 
 
                                                   
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

# cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ..

# project name
project(speedcheck)

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Wextra -pedantic -Werror -Wno-multichar")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wno-multichar")

set(CMAKE_CXX_STANDARD 11)
# Some cmake versions can't understand the CMAKE_CXX_STANDARD option above?
SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -std=c++11" )

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

file(GLOB_RECURSE SPEEDCHECK_SOURCES src/*.cpp)
file(GLOB_RECURSE SPEEDCHECK_UIS src/ui/*.ui)
file(GLOB_RECURSE SPEEDCHECK_RESOURCES src/*.qrc)
file(GLOB_RECURSE SPEEDCHECK_TSS src/i18n/*.ts)

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/src
  ${CMAKE_CURRENT_BINARY_DIR}
)

#
# Qt5
#
find_package(Qt5 COMPONENTS Widgets Network LinguistTools REQUIRED)

QT5_WRAP_UI(SPEEDCHECK_UI_HEADERS ${SPEEDCHECK_UIS})

option(UPDATE_TRANSLATIONS "Update .ts files (WARNING: make clean will delete the .ts files!)")
if(SPEEDCHECK_TSS)
  if (UPDATE_TRANSLATIONS)
    set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${SPEEDCHECK_SOURCES} ${SPEEDCHECK_UIS})
    QT5_CREATE_TRANSLATION(SPEEDCHECK_QMS ${FILES_TO_TRANSLATE} ${SPEEDCHECK_TSS} OPTIONS -noobsolete)
    message(STATUS ".tr files have been updated")
  else (UPDATE_TRANSLATIONS)
    QT5_ADD_TRANSLATION(SPEEDCHECK_QMS ${SPEEDCHECK_TSS})
  endif (UPDATE_TRANSLATIONS)

  # write a resource file for qm files
  set(resource_file_content "<RCC>\n    <qresource prefix=\"/\">\n")
  foreach(file ${SPEEDCHECK_QMS})
    get_filename_component(filename ${file} NAME)
    set(resource_file_content "${resource_file_content}        <file>${filename}</file>\n")
  endforeach(file)
  set(resource_file_content "${resource_file_content}    </qresource>\n</RCC>\n")
  file(WRITE "${CMAKE_BINARY_DIR}/translation.qrc" "${resource_file_content}")
  set(SPEEDCHECK_RESOURCES ${SPEEDCHECK_RESOURCES} "${CMAKE_BINARY_DIR}/translation.qrc")

  #add_custom_target(translations_target DEPENDS ${SPEEDCHECK_QMS})
endif(SPEEDCHECK_TSS)

QT5_ADD_RESOURCES(SPEEDCHECK_RC_SOURCES ${SPEEDCHECK_RESOURCES})

#
# build speedcheck
#
add_executable(speedcheck
  ${SPEEDCHECK_SOURCES}
  ${SPEEDCHECK_UI_HEADERS}
  ${SPEEDCHECK_RC_SOURCES}
  ${SPEEDCHECK_QMS}
)

target_link_libraries(speedcheck
  Qt5::Widgets
  Qt5::Network
)

install(TARGETS speedcheck RUNTIME DESTINATION bin)