diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 29b9459c9d..13c89dcd31 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -303,6 +303,9 @@ set(COMMON_FLAG "-pipe -fvisibility=hidden -pthread -fno-builtin-strcmp -fno-bui if (DISABLE_SVU) set(COMMON_FLAG "${COMMON_FLAG} -DDISABLE_SVU") endif() +if(USE_VTUNE) + set(COMMON_FLAG "${COMMON_FLAG} -DENABLE_VTUNE") +endif() set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") # -Wno-attributes: "always_inline function might not be inlinable" <= real spam (thousand of warnings!!!) # -Wno-missing-field-initializers: standard allow to init only the begin of struct/array in static init. Just a silly warning. diff --git a/cmake/FindVtune.cmake b/cmake/FindVtune.cmake new file mode 100644 index 0000000000..dc5c0a14a5 --- /dev/null +++ b/cmake/FindVtune.cmake @@ -0,0 +1,33 @@ +# Find Intel's VTUNE tool + +# VTUNE_FOUND found Vtune +# VTUNE_INCLUDE_DIRS include path to jitprofiling.h +# VTUNE_LIBRARIES path to vtune libs + +find_path(VTUNE_INCLUDE_DIRS NAMES jitprofiling.h PATHS + /opt/intel/vtune_amplifier_xe_2018/include + /opt/intel/vtune_amplifier_xe_2017/include + /opt/intel/vtune_amplifier_xe_2016/include + ) + +if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") + find_library(VTUNE_LIBRARIES NAMES libjitprofiling.a PATHS + /opt/intel/vtune_amplifier_xe_2018/lib32 + /opt/intel/vtune_amplifier_xe_2017/lib32 + /opt/intel/vtune_amplifier_xe_2016/lib32 + ) +else() + find_library(VTUNE_LIBRARIES NAMES libjitprofiling.a PATHS + /opt/intel/vtune_amplifier_xe_2018/lib64 + /opt/intel/vtune_amplifier_xe_2017/lib64 + /opt/intel/vtune_amplifier_xe_2016/lib64 + ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set VTUNE_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vtune DEFAULT_MSG VTUNE_LIBRARIES VTUNE_INCLUDE_DIRS) + +mark_as_advanced(VTUNE_FOUND VTUNE_INCLUDE_DIRS VTUNE_LIBRARIES) + diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index ec4f0e89fc..94c91fd7c8 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -12,6 +12,7 @@ endif() find_package(LibLZMA) find_package(OpenGL) find_package(PNG) +find_package(Vtune) # The requirement of wxWidgets is checked in SelectPcsx2Plugins module # Does not require the module (allow to compile non-wx plugins) # Force the unicode build (the variable is only supported on cmake 2.8.3 and above) @@ -156,6 +157,10 @@ if(SDL_FOUND AND NOT SDL2_API) include_directories(${SDL_INCLUDE_DIR}) endif() +if(USE_VTUNE AND VTUNE_FOUND) + include_directories(${VTUNE_INCLUDE_DIRS}) +endif() + if(wxWidgets_FOUND) include(${wxWidgets_USE_FILE}) endif() diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index 4def9fa953..86fc6bcca5 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -107,10 +107,5 @@ set(UtilitiesFinalLibs ${wxWidgets_LIBRARIES} ) -if(USE_VTUNE) - set(UtilitiesFinalFlags ${UtilitiesFinalFlags} -DENABLE_VTUNE) - include_directories("$ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/include") -endif() - add_pcsx2_lib(${Output} "${UtilitiesFinalSources}" "${UtilitiesFinalLibs}" "${UtilitiesFinalFlags}") add_pcsx2_lib(${Output}_NO_TLS "${UtilitiesFinalSources}" "${UtilitiesFinalLibs}" "${UtilitiesFinalFlags} -DPCSX2_THREAD_LOCAL=0") diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index aa0e8dfbe6..f8c36b269a 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -682,13 +682,7 @@ foreach(res_file IN ITEMS endforeach() if(USE_VTUNE) - set(pcsx2FinalFlags ${pcsx2FinalFlags} -DENABLE_VTUNE) - include_directories("$ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/include") - if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") - set(pcsx2FinalLibs ${pcsx2FinalLibs} $ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/lib32/libjitprofiling.a) - else() - set(pcsx2FinalLibs ${pcsx2FinalLibs} $ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/lib64/libjitprofiling.a) - endif() + set(pcsx2FinalLibs ${pcsx2FinalLibs} ${VTUNE_LIBRARIES}) endif() # Suppress all the system-specific predefined macros outside the reserved namespace. diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index e98c5ac28c..886682eb84 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -204,13 +204,7 @@ if(LIBLZMA_FOUND) endif() if(USE_VTUNE) - set(GSdxFinalFlags ${GSdxFinalFlags} -DENABLE_VTUNE) - include_directories("$ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/include") - if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") - set(GSdxFinalLibs ${GSdxFinalLibs} $ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/lib32/libjitprofiling.a) - else() - set(GSdxFinalLibs ${GSdxFinalLibs} $ENV{VTUNE_AMPLIFIER_XE_2016_DIR}/lib64/libjitprofiling.a) - endif() + set(GSdxFinalLibs ${GSdxFinalLibs} ${VTUNE_LIBRARIES}) endif() # Generate Glsl header file. Protect with REBUILD_SHADER to avoid build-dependency on PERL