From 459234e91a9d10b9dd0dda50e7a142b2df2d505f Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 18 Sep 2016 20:24:04 +0100 Subject: [PATCH] Misc. changes to support Linux builds --- CMakeLists.txt | 22 +++++++++++++++++++--- src/test.py | 8 ++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ed858b..7db204f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,9 +48,15 @@ add_subdirectory(${PYBIND11_EXTRACTED_PATH}) # LOOT API ####################################### +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(LOOT_API_URL "https://bintray.com/wrinklyninja/loot/download_file?file_path=loot-api_0.9.2-74-g6809c39_dev.7z") +else() + set(LOOT_API_URL "https://bintray.com/wrinklyninja/loot/download_file?file_path=loot-api_0.9.2-74-g6809c39_dev.tar.xz") +endif() + ExternalProject_Add(loot-api-c++ PREFIX "external" - URL "https://bintray.com/wrinklyninja/loot/download_file?file_path=loot-api_0.9.2-74-g6809c39_dev.7z" + URL ${LOOT_API_URL} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "") @@ -81,7 +87,12 @@ ExternalProject_Add(test-masterlist pybind11_add_module(loot_api "${CMAKE_SOURCE_DIR}/src/main.cpp" "${CMAKE_BINARY_DIR}/generated/wrapper_version.cpp") add_dependencies(loot_api loot-api-c++ test-masterlist) -target_link_libraries(loot_api PRIVATE ${LOOT_API_STATIC_LIBRARY}) + +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + target_link_libraries(loot_api PRIVATE ${LOOT_API_STATIC_LIBRARY}) +else() + target_link_libraries(loot_api PRIVATE ${LOOT_API_SHARED_LIBRARY}) +endif() ######################################## # Testing @@ -143,7 +154,12 @@ ELSE() SET (GIT_DESCRIBE_STRING "unknown-version") ENDIF () -set(CPACK_GENERATOR "7Z") +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(CPACK_GENERATOR "7Z") +else() + set(CPACK_GENERATOR "TXZ") +endif() + set(CPACK_PACKAGE_VERSION ${GIT_DESCRIBE_STRING}) set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/package") diff --git a/src/test.py b/src/test.py index 0f52b8c..57fc64e 100644 --- a/src/test.py +++ b/src/test.py @@ -15,6 +15,7 @@ from loot_api import is_compatible class GameFixture(unittest.TestCase): game_path = os.path.join(u'.', u'Oblivion') + local_path = os.path.join(u'.', u'local') def setUp(self): data_path = os.path.join(self.game_path, 'Data') @@ -23,8 +24,11 @@ class GameFixture(unittest.TestCase): os.makedirs(data_path) open(master_file, 'a').close() + os.makedirs(self.local_path) + def tearDown(self): shutil.rmtree(self.game_path) + shutil.rmtree(self.local_path) class TestLootApi(GameFixture): def test_is_compatible(self): @@ -45,7 +49,7 @@ class TestLootApi(GameFixture): self.assertNotEqual(WrapperVersion.revision, Version.revision) def test_create_db(self): - db = create_database(GameType.tes4, self.game_path, u'') + db = create_database(GameType.tes4, self.game_path, self.local_path) self.assertNotEqual(db, None) class TestDatabaseInterface(GameFixture): @@ -54,7 +58,7 @@ class TestDatabaseInterface(GameFixture): def setUp(self): super(TestDatabaseInterface, self).setUp() - self.db = create_database(GameType.tes4, self.game_path, u'') + self.db = create_database(GameType.tes4, self.game_path, self.local_path) def test_load_lists(self): self.db.load_lists(self.masterlist_path, u'')