Merge pull request #31 from BtbN/cmake

More cmake adjustments
This commit is contained in:
Jim 2014-01-25 17:13:19 -08:00
commit 31f9e3ef53
5 changed files with 120 additions and 27 deletions

View file

@ -73,8 +73,10 @@ obs_install_additional()
# CPack Configuration
if(APPLE)
if(APPLE AND NOT CPACK_GENERATOR)
set(CPACK_GENERATOR "Bundle")
elseif(WIN32 AND NOT CPACK_GENERATOR)
set(CPACK_GENERATOR "NSIS" "ZIP")
endif()
set(CPACK_PACKAGE_NAME "OBS Studio")
@ -86,15 +88,27 @@ set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OBS Studio - Multi-platform broadcasting software")
if(INSTALLER_RUN)
file(TO_NATIVE_PATH "${OBS_EXECUTABLE32_DESTINATION}/obs" _obs32)
file(TO_NATIVE_PATH "${OBS_EXECUTABLE64_DESTINATION}/obs" _obs64)
#Workaround a cmake bug, remove when fixed
string(REPLACE "\\" "\\\\" _obs32 "${_obs32}")
string(REPLACE "\\" "\\\\" _obs64 "${_obs64}")
set(CPACK_PACKAGE_EXECUTABLES
"${OBS_EXECUTABLE32_DESTINATION}/obs" "OBS Studio (32bit)"
"${OBS_EXECUTABLE64_DESTINATION}/obs" "OBS Studio (64bit)")
"${_obs32}" "OBS Studio (32bit)"
"${_obs64}" "OBS Studio (64bit)")
set(CPACK_CREATE_DESKTOP_LINKS
"${OBS_EXECUTABLE32_DESTINATION}/obs"
"${OBS_EXECUTABLE64_DESTINATION}/obs")
"${_obs32}"
"${_obs64}")
else()
set(CPACK_PACKAGE_EXECUTABLES "${OBS_EXECUTABLE_DESTINATION}/obs;OBS Studio")
set(CPACK_CREATE_DESKTOP_LINKS "${OBS_EXECUTABLE_DESTINATION}/obs")
file(TO_NATIVE_PATH "${OBS_EXECUTABLE_DESTINATION}/obs" _obs)
#Workaround a cmake bug, remove when fixed
string(REPLACE "\\" "\\\\" _obs "${_obs}")
set(CPACK_PACKAGE_EXECUTABLES "${_obs}" "OBS Studio")
set(CPACK_CREATE_DESKTOP_LINKS "${_obs}")
endif()
set(CPACK_BUNDLE_NAME "OBS Studio")
@ -107,20 +121,23 @@ set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
set(CPACK_NSIS_MODIFY_PATH ON)
if(INSTALLER_RUN)
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio")
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
set(CPACK_PACKAGE_FILE_NAME "obs-studio")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(WIN32)
set(CPACK_PACKAGE_NAME "OBS Studio (64bit)")
endif()
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio64")
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio64")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_PACKAGE_FILE_NAME "obs-studio-x64")
else()
if(WIN32)
set(CPACK_PACKAGE_NAME "OBS Studio (32bit)")
endif()
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio32")
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES32")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OBSStudio32")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES32")
set(CPACK_PACKAGE_FILE_NAME "obs-studio-x86")
endif()
include(CPack)

View file

@ -19,6 +19,14 @@ if(INSTALLER_RUN AND NOT DEFINED ENV{obsInstallerTempDir})
message(FATAL_ERROR "Environment variable obsInstallerTempDir is needed for multiarch installer generation")
endif()
if(DEFINED ENV{obsInstallerTempDir})
file(TO_CMAKE_PATH "$ENV{obsInstallerTempDir}" ENV{obsInstallerTempDir})
endif()
if(DEFINED ENV{obsAdditionalInstallFiles})
file(TO_CMAKE_PATH "$ENV{obsAdditionalInstallFiles}" ENV{obsAdditionalInstallFiles})
endif()
if(NOT UNIX_STRUCTURE)
set(OBS_DATA_DESTINATION "data")
if(APPLE)

View file

@ -63,6 +63,11 @@ char *find_plugin(const char *plugin)
if (check_lib_path(plugin, "../../obs-plugins/32bit/", &output))
return output.array;
}
else
{
if (check_lib_path(plugin, "../../obs-plugins/64bit/", &output))
return output.array;
}
if (OBS_INSTALL_PREFIX [0] != 0)
{

View file

@ -20,33 +20,84 @@
#include "obs.h"
#include "obs-data.h"
static inline bool check_path(const char* data, const char *path,
struct dstr * output)
{
dstr_copy(output, path);
dstr_cat(output, data);
blog(LOG_INFO, "Attempting path: %s\n", output->array);
return os_file_exists(output->array);
}
static inline bool check_lib_path(const char* data, const char *path,
struct dstr *output)
{
bool result = false;
struct dstr tmp;
dstr_init_copy(&tmp, data);
dstr_cat(&tmp, ".dll");
result = check_path(tmp.array, path, output);
dstr_free(&tmp);
return result;
}
/* on windows, plugin files are located in [base directory]/plugins/[bit] */
char *find_plugin(const char *plugin)
{
struct dstr path;
dstr_init(&path);
#ifdef _WIN64
dstr_init_copy(&path, "../../obs-plugins/64bit/");
if (check_lib_path(plugin, "obs-plugins/64bit/", &path))
#else
dstr_init_copy(&path, "../../obs-plugins/32bit/");
if (check_lib_path(plugin, "obs-plugins/32bit/", &path))
#endif
dstr_cat(&path, plugin);
return path.array;
return path.array;
#ifdef _WIN64
if (check_lib_path(plugin, "../../obs-plugins/64bit/", &path))
#else
if (check_lib_path(plugin, "../../obs-plugins/32bit/", &path))
#endif
return path.array;
dstr_free(&path);
return NULL;
}
/* on windows, points to [base directory]/libobs */
char *find_libobs_data_file(const char *file)
{
struct dstr path;
dstr_init_copy(&path, "../../data/libobs/");
dstr_cat(&path, file);
return path.array;
dstr_init(&path);
if (check_path(file, "data/libobs/", &path))
return path.array;
if (check_path(file, "../../data/libobs/", &path))
return path.array;
dstr_free(&path);
return NULL;
}
/* on windows, data files should always be in [base directory]/data */
char *obs_find_plugin_file(const char *file)
{
struct dstr path;
dstr_init_copy(&path, "../../data/obs-plugins/");
dstr_cat(&path, file);
return path.array;
dstr_init(&path);
if (check_path(file, "data/obs-plugins/", &path))
return path.array;
if (check_path(file, "../../data/obs-plugins/", &path))
return path.array;
dstr_free(&path);
return NULL;
}

View file

@ -24,12 +24,24 @@ using namespace std;
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static inline bool check_path(const char* data, const char *path,
string &output)
{
ostringstream str;
str << path << data;
output = str.str();
printf("Attempted path: %s\n", output.c_str());
return os_file_exists(output.c_str());
}
bool GetDataFilePath(const char *data, string &output)
{
stringstream str;
str << OBS_DATA_PATH "/obs-studio/" << data;
output = str.str();
return os_file_exists(output.c_str());
if (check_path(data, "data/obs-studio/", output))
return true;
return check_path(data, OBS_DATA_PATH "/obs-studio/", output);
}
static BOOL CALLBACK OBSMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor,