Cleanup in progress.

This commit is contained in:
NissimHadar 2019-01-18 12:20:05 -08:00
parent 6293c84f17
commit 74d5e4891c

View file

@ -1,12 +1,6 @@
set(TARGET_NAME nitpick) set(TARGET_NAME nitpick)
project(${TARGET_NAME}) project(${TARGET_NAME})
function(JOIN VALUES GLUE OUTPUT)
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
set(CUSTOM_NITPICK_QRC_PATHS "") set(CUSTOM_NITPICK_QRC_PATHS "")
find_npm() find_npm()
@ -16,16 +10,16 @@ set(RESOURCES_RCC ${CMAKE_CURRENT_SOURCE_DIR}/compiledResources/resources.rcc)
generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources CUSTOM_PATHS ${CUSTOM_NITPICK_QRC_PATHS} GLOBS *) generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources CUSTOM_PATHS ${CUSTOM_NITPICK_QRC_PATHS} GLOBS *)
add_custom_command( add_custom_command(
OUTPUT ${RESOURCES_RCC} OUTPUT ${RESOURCES_RCC}
DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS} DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
COMMAND "${QT_DIR}/bin/rcc" COMMAND "${QT_DIR}/bin/rcc"
ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC} ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC}
) )
if (WIN32) if (WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -bigobj") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -bigobj")
add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h
add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines
endif() endif()
# grab the implementation and header files from src dirs # grab the implementation and header files from src dirs
@ -34,9 +28,9 @@ GroupSources("src")
list(APPEND NITPICK_SRCS ${RESOURCES_RCC}) list(APPEND NITPICK_SRCS ${RESOURCES_RCC})
find_package( find_package(
Qt5 COMPONENTS Qt5 COMPONENTS
Gui Widgets Multimedia Network Qml Quick Script Svg Xml Gui Widgets Multimedia Network Qml Quick Script Svg Xml
${PLATFORM_QT_COMPONENTS} ${PLATFORM_QT_COMPONENTS}
) )
# grab the ui files in ui # grab the ui files in ui
@ -50,50 +44,50 @@ qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
set(NITPICK_SRCS ${NITPICK_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}") set(NITPICK_SRCS ${NITPICK_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}")
if (APPLE) if (APPLE)
# configure CMake to use a custom Info.plist # configure CMake to use a custom Info.plist
set_target_properties(${this_target} PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.in) set_target_properties(${this_target} PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.in)
if (PRODUCTION_BUILD) if (PRODUCTION_BUILD)
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick) set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick)
else () else ()
if (DEV_BUILD) if (DEV_BUILD)
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick-dev) set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick-dev)
elseif (PR_BUILD) elseif (PR_BUILD)
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick-pr) set(MACOSX_BUNDLE_GUI_IDENTIFIER com.highfidelity.nitpick-pr)
endif ()
endif () endif ()
endif ()
# set how the icon shows up in the Info.plist file # set how the icon shows up in the Info.plist file
set(MACOSX_BUNDLE_ICON_FILE "${NITPICK_ICON_FILENAME}") set(MACOSX_BUNDLE_ICON_FILE "${NITPICK_ICON_FILENAME}")
# set where in the bundle to put the resources file # set where in the bundle to put the resources file
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# append the discovered resources to our list of nitpick sources # append the discovered resources to our list of nitpick sources
list(APPEND NITPICK_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME}) list(APPEND NITPICK_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME})
endif() endif()
# create the executable, make it a bundle on OS X # create the executable, make it a bundle on OS X
if (APPLE) if (APPLE)
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${NITPICK_SRCS} ${QM}) add_executable(${TARGET_NAME} MACOSX_BUNDLE ${NITPICK_SRCS} ${QM})
# make sure the output name for the .app bundle is correct # make sure the output name for the .app bundle is correct
# Fix up the rpath so macdeployqt works # Fix up the rpath so macdeployqt works
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks") set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks")
elseif (WIN32) elseif (WIN32)
# configure an rc file for the chosen icon # configure an rc file for the chosen icon
set(CONFIGURE_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME}") set(CONFIGURE_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icon/${NITPICK_ICON_FILENAME}")
set(CONFIGURE_ICON_RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Icon.rc") set(CONFIGURE_ICON_RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Icon.rc")
configure_file("${HF_CMAKE_DIR}/templates/Icon.rc.in" ${CONFIGURE_ICON_RC_OUTPUT}) configure_file("${HF_CMAKE_DIR}/templates/Icon.rc.in" ${CONFIGURE_ICON_RC_OUTPUT})
set(APP_FULL_NAME "High Fidelity Nitpick") set(APP_FULL_NAME "High Fidelity Nitpick")
set(CONFIGURE_VERSION_INFO_RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.rc") set(CONFIGURE_VERSION_INFO_RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.rc")
configure_file("${HF_CMAKE_DIR}/templates/VersionInfo.rc.in" ${CONFIGURE_VERSION_INFO_RC_OUTPUT}) configure_file("${HF_CMAKE_DIR}/templates/VersionInfo.rc.in" ${CONFIGURE_VERSION_INFO_RC_OUTPUT})
# add an executable that also has the icon itself and the configured rc file as resources # add an executable that also has the icon itself and the configured rc file as resources
add_executable(${TARGET_NAME} WIN32 ${NITPICK_SRCS} ${QM} ${CONFIGURE_ICON_RC_OUTPUT} ${CONFIGURE_VERSION_INFO_RC_OUTPUT}) add_executable(${TARGET_NAME} WIN32 ${NITPICK_SRCS} ${QM} ${CONFIGURE_ICON_RC_OUTPUT} ${CONFIGURE_VERSION_INFO_RC_OUTPUT})
else () else ()
add_executable(${TARGET_NAME} ${NITPICK_SRCS} ${QM}) add_executable(${TARGET_NAME} ${NITPICK_SRCS} ${QM})
endif () endif ()
add_dependencies(${TARGET_NAME} resources) add_dependencies(${TARGET_NAME} resources)
@ -102,46 +96,46 @@ add_dependencies(${TARGET_NAME} resources)
# This will prevent the following linker warnings # This will prevent the following linker warnings
# LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification # LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
if (WIN32) if (WIN32)
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF") set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
endif() endif()
link_hifi_libraries(entities-renderer) link_hifi_libraries(entities-renderer)
# perform standard include and linking for found externals # perform standard include and linking for found externals
foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
if (${${EXTERNAL}_UPPERCASE}_REQUIRED) if (${${EXTERNAL}_UPPERCASE}_REQUIRED)
find_package(${EXTERNAL} REQUIRED) find_package(${EXTERNAL} REQUIRED)
else () else ()
find_package(${EXTERNAL}) find_package(${EXTERNAL})
endif ()
if (${${EXTERNAL}_UPPERCASE}_FOUND AND NOT DISABLE_${${EXTERNAL}_UPPERCASE})
add_definitions(-DHAVE_${${EXTERNAL}_UPPERCASE})
# include the library directories (ignoring warnings)
if (NOT ${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS)
set(${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIR})
endif () endif ()
include_directories(SYSTEM ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS}) if (${${EXTERNAL}_UPPERCASE}_FOUND AND NOT DISABLE_${${EXTERNAL}_UPPERCASE})
add_definitions(-DHAVE_${${EXTERNAL}_UPPERCASE})
# perform the system include hack for OS X to ignore warnings # include the library directories (ignoring warnings)
if (APPLE) if (NOT ${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS)
foreach(EXTERNAL_INCLUDE_DIR ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS}) set(${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIR})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}") endif ()
endforeach()
endif ()
if (NOT ${${EXTERNAL}_UPPERCASE}_LIBRARIES) include_directories(SYSTEM ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS})
set(${${EXTERNAL}_UPPERCASE}_LIBRARIES ${${${EXTERNAL}_UPPERCASE}_LIBRARY})
endif ()
if (NOT APPLE OR NOT ${${EXTERNAL}_UPPERCASE} MATCHES "SIXENSE") # perform the system include hack for OS X to ignore warnings
target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES}) if (APPLE)
elseif (APPLE AND NOT INSTALLER_BUILD) foreach(EXTERNAL_INCLUDE_DIR ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS})
add_definitions(-DSIXENSE_LIB_FILENAME=\"${${${EXTERNAL}_UPPERCASE}_LIBRARY_RELEASE}\") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}")
endforeach()
endif ()
if (NOT ${${EXTERNAL}_UPPERCASE}_LIBRARIES)
set(${${EXTERNAL}_UPPERCASE}_LIBRARIES ${${${EXTERNAL}_UPPERCASE}_LIBRARY})
endif ()
if (NOT APPLE OR NOT ${${EXTERNAL}_UPPERCASE} MATCHES "SIXENSE")
target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES})
elseif (APPLE AND NOT INSTALLER_BUILD)
add_definitions(-DSIXENSE_LIB_FILENAME=\"${${${EXTERNAL}_UPPERCASE}_LIBRARY_RELEASE}\")
endif ()
endif () endif ()
endif ()
endforeach() endforeach()
# include headers for nitpick and NitpickConfig. # include headers for nitpick and NitpickConfig.
@ -160,62 +154,12 @@ endif()
# assume we are using a Qt build without bearer management # assume we are using a Qt build without bearer management
add_definitions(-DQT_NO_BEARERMANAGEMENT) add_definitions(-DQT_NO_BEARERMANAGEMENT)
if (APPLE) # add a custom command to copy the empty AppData High Fidelity folder (i.e. - a valid folder with no entities)
# link in required OS X frameworks and include the right GL headers if (WIN32)
find_library(OpenGL OpenGL)
find_library(AppKit AppKit)
target_link_libraries(${TARGET_NAME} ${OpenGL} ${AppKit})
# setup install of OS X nitpick bundle
install(TARGETS ${TARGET_NAME}
BUNDLE DESTINATION ${NITPICK_INSTALL_DIR}
COMPONENT ${CLIENT_COMPONENT}
)
# call the fixup_nitpick macro to add required bundling commands for installation
fixup_nitpick()
# add a custom command to copy the empty AppData High Fidelity folder (i.e. - a valid folder with no entities)
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "$<TARGET_FILE_DIR:${TARGET_NAME}>/AppDataHighFidelity"
)
else()
set(NITPICK_EXEC_DIR "$<TARGET_FILE_DIR:${TARGET_NAME}>")
set(RESOURCES_DEV_DIR "${NITPICK_EXEC_DIR}/resources")
# copy the resources files beside the executable
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${RESOURCES_RCC}"
"${NITPICK_EXEC_DIR}"
)
# link target to external libraries
if (WIN32)
# setup install of executable and things copied by fixup/windeployqt
install(
DIRECTORY "$<TARGET_FILE_DIR:${TARGET_NAME}>/"
DESTINATION ${NITPICK_INSTALL_DIR}
COMPONENT ${CLIENT_COMPONENT}
PATTERN "*.pdb" EXCLUDE
PATTERN "*.lib" EXCLUDE
PATTERN "*.exp" EXCLUDE
)
set(SCRIPTS_INSTALL_DIR "${NITPICK_INSTALL_DIR}")
set(EXECUTABLE_COMPONENT ${CLIENT_COMPONENT})
optional_win_executable_signing()
# add a custom command to copy the empty AppData High Fidelity folder (i.e. - a valid folder with no entities)
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
POST_BUILD POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "$<TARGET_FILE_DIR:${TARGET_NAME}>/AppDataHighFidelity" COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "$<TARGET_FILE_DIR:${TARGET_NAME}>/AppDataHighFidelity"
) )
if (RELEASE_TYPE STREQUAL "DEV") if (RELEASE_TYPE STREQUAL "DEV")
@ -226,7 +170,46 @@ else()
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "AppDataHighFidelity" COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "AppDataHighFidelity"
) )
endif () endif ()
endif() elseif (APPLE)
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/AppDataHighFidelity" "$<TARGET_FILE_DIR:${TARGET_NAME}>/AppDataHighFidelity"
)
endif()
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
find_library(AppKit AppKit)
target_link_libraries(${TARGET_NAME} ${OpenGL} ${AppKit})
# setup install of OS X nitpick bundle
install(TARGETS ${TARGET_NAME}
BUNDLE DESTINATION ${NITPICK_INSTALL_DIR}
COMPONENT ${CLIENT_COMPONENT}
)
# call the fixup_nitpick macro to add required bundling commands for installation
fixup_nitpick()
elseif (WIN32)
# link target to external libraries
# setup install of executable and things copied by fixup/windeployqt
install(
DIRECTORY "$<TARGET_FILE_DIR:${TARGET_NAME}>/"
DESTINATION ${NITPICK_INSTALL_DIR}
COMPONENT ${CLIENT_COMPONENT}
PATTERN "*.pdb" EXCLUDE
PATTERN "*.lib" EXCLUDE
PATTERN "*.exp" EXCLUDE
)
set(SCRIPTS_INSTALL_DIR "${NITPICK_INSTALL_DIR}")
set(EXECUTABLE_COMPONENT ${CLIENT_COMPONENT})
optional_win_executable_signing()
endif() endif()
if (WIN32) if (WIN32)
@ -238,6 +221,3 @@ if (WIN32)
package_libraries_for_deployment() package_libraries_for_deployment()
endif() endif()
# tell CMake to exclude ui_console.h for policy CMP0071
set_property(SOURCE ui_console.h PROPERTY SKIP_AUTOMOC ON)