diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fe2254..dbe3c13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,14 @@ cmake_minimum_required (VERSION 3.0) project (CBash) +include(CMakeToolsHelpers OPTIONAL) + add_subdirectory (deps/pybind11) LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/deps/cotire/CMake") include(cotire) +set_property(DIRECTORY . PROPERTY COTIRE_ADD_UNITY_BUILD FALSE) + option(CBash_BUILD_SHARED_LIBS "Build a shared library" ON) option(CBash_USE_STATIC_RUNTIME "Build with static runtime libs (/MT)" ON) option(CBash_NO_BOOST_ZLIB "Build with external Zlib" ON) @@ -30,60 +34,6 @@ set(CBASH_TESTS ${CMAKE_SOURCE_DIR}/tests) set(CBASH_SOURCE ${CMAKE_SOURCE_DIR}/src) set(CBASH_INCLUDE ${CMAKE_SOURCE_DIR}/include/cbash) -file (GLOB_RECURSE CBASH_GEN_HDRS "${CBASH_SOURCE}/*.h" ) -file (GLOB_RECURSE CBASH_PUB_HDRS "${CBASH_INCLUDE}/*.h" ) - -file (GLOB_RECURSE CBASH_FONV "${CBASH_SOURCE}/FalloutNewVegas/*.cpp") -file (GLOB_RECURSE CBASH_OBLIVION "${CBASH_SOURCE}/Oblivion/*.cpp") -file (GLOB_RECURSE CBASH_SKYRIM "${CBASH_SOURCE}/Skyrim/*.cpp") - -set (CBASH_SRC "${CBASH_SOURCE}/CBash.cpp" - "${CBASH_SOURCE}/Collection.cpp" - "${CBASH_SOURCE}/Common.cpp" - "${CBASH_SOURCE}/GenericChunks.cpp" - "${CBASH_SOURCE}/GenericRecord.cpp" - "${CBASH_SOURCE}/ModFile.cpp" - "${CBASH_SOURCE}/TES4Record.cpp" - "${CBASH_SOURCE}/TES4RecordAPI.cpp" - "${CBASH_SOURCE}/Visitors.cpp" - "${CBASH_SOURCE}/CBash.rc" - ${CBASH_FONV} - ${CBASH_OBLIVION} - ${CBASH_SKYRIM} - ) - -file(GLOB_RECURSE TMP_FILES_HDRS - "${CBASH_SOURCE}/*.h" -) - -foreach(f ${TMP_FILES_HDRS}) - # Get the path of the file relative to ${DIRECTORY}, - # then alter it (not compulsory) - file(RELATIVE_PATH SRCGR "${CBASH_SOURCE}/" ${f}) - set(SRCGR "Headers/${SRCGR}") - - # Extract the folder, ie remove the filename part - string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR}) - - # Source_group expects \\ (double antislash), not / (slash) - string(REPLACE / \\ SRCGR ${SRCGR}) - source_group("${SRCGR}" FILES ${f}) -endforeach() - -file(GLOB_RECURSE TMP_FILES - "${CBASH_SOURCE}/*.cpp" -) -foreach(f ${TMP_FILES}) - # Get the path of the file relative to ${DIRECTORY}, - # then alter it (not compulsory) - file(RELATIVE_PATH SRCGR "${CBASH_SOURCE}/" ${f}) - set(SRCGR "Source Files/${SRCGR}") - # Extract the folder, ie remove the filename part - string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR}) - # Source_group expects \\ (double antislash), not / (slash) - string(REPLACE / \\ SRCGR ${SRCGR}) - source_group("${SRCGR}" FILES ${f}) -endforeach() IF (CBash_NO_BOOST_ZLIB) add_definitions(-DCBash_NO_BOOST_ZLIB) @@ -97,9 +47,13 @@ ELSE () ENDIF () # Include source and library directories. -include_directories (${CBASH_INCLUDE} - ${Boost_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIR}) +include_directories ( + ${CBASH_INCLUDE} + ${Boost_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} + ${CBASH_SOURCE} + ${CBASH_SOURCE}/game +) ############################## @@ -139,26 +93,9 @@ IF (MSVC) ENDIF () -############################## -# Actual Building -############################## - -# Build CBash. -add_library (CBash ${CBASH_SRC} ${CBASH_PUB_HDRS} ${CBASH_GEN_HDRS}) -target_link_libraries (CBash ${Boost_LIBRARIES} ${CBASH_LIBS}) - -# Always write the output file directly into the 'tests' directory (even on MSVC) -if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set_target_properties(CBash PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CBASH_RELEASE}) - set_target_properties(CBash PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CBASH_RELEASE}) - foreach(config ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${config} config) - set_target_properties(CBash PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} ${CBASH_RELEASE}) - set_target_properties(CBash PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${config} ${CBASH_RELEASE}) - endforeach() -endif() - +add_subdirectory(src/common) +add_subdirectory(src/game) +add_subdirectory(src/main) +add_subdirectory(src/capi) add_subdirectory (pyd) -cotire(CBash) - diff --git a/pyd/CMakeLists.txt b/pyd/CMakeLists.txt index 42aaf55..96563e9 100644 --- a/pyd/CMakeLists.txt +++ b/pyd/CMakeLists.txt @@ -20,7 +20,7 @@ pybind11_enable_warnings(cint) #set_property(TARGET CBash PROPERTY IMPORTED_LOCATION "/home/sources/lib/libfoo1.so") -target_link_libraries (cint PRIVATE CBash) +target_link_libraries (cint PRIVATE libmain libgame libcommon) # Always write the output file directly into the 'tests' directory (even on MSVC) if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) diff --git a/src/capi/CMakeLists.txt b/src/capi/CMakeLists.txt new file mode 100644 index 0000000..14bf0ca --- /dev/null +++ b/src/capi/CMakeLists.txt @@ -0,0 +1,49 @@ +# Settings passed on the command line: +# +# CBash_BUILD_SHARED_LIBS +# CBash_USE_STATIC_RUNTIME +# CBash_NO_BOOST_ZLIB + +############################## +# General Settings +############################## + + +file (GLOB_RECURSE CBASH_HEADERS "${CBASH_INCLUDE}/*.h" ) + +list(APPEND CBASH_HEADERS + "Version.h" + "resource.h" +) + +set (CBASH_SOURCES + "CBash.cpp" + "CBash.rc" + ) + + +# Include source and library directories. +include_directories (${CBASH_INCLUDE} ${CBASH_SOURCE} ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + +############################## +# Actual Building +############################## + +# Build CBash. +add_library (CBash ${CBASH_SOURCES} ${CBASH_HEADERS} ${CBASH_GEN_HDRS}) +target_link_libraries (CBash ${Boost_LIBRARIES} ${CBASH_LIBS} libcommon libgame libmain) + + +# Always write the output file directly into the 'tests' directory (even on MSVC) +if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set_target_properties(CBash PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CBASH_RELEASE}) + set_target_properties(CBash PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CBASH_RELEASE}) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${config} config) + set_target_properties(CBash PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} ${CBASH_RELEASE}) + set_target_properties(CBash PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${config} ${CBASH_RELEASE}) + endforeach() +endif() + +cotire(CBash) + diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 0000000..3c2d014 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,31 @@ + +# Include source and library directories. +# include_directories (${CBASH_INCLUDE} +# ${Boost_INCLUDE_DIRS} +# ${ZLIB_INCLUDE_DIR}) + +set (COMMON_HEADERS + "Allocator.h" + "Common.h" + "GenericChunks.h" + "GenericRecord.h" + "MacroDefinitions.h" + "ModFile.h" + "TES4Record.h" + ) + +set (COMMON_SOURCES + + "Common.cpp" + "GenericChunks.cpp" + "GenericRecord.cpp" + "ModFile.cpp" + "TES4Record.cpp" + "TES4RecordAPI.cpp" + ) + +include_directories (${CBASH_INCLUDE} ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + +add_library(libcommon STATIC ${COMMON_HEADERS} ${COMMON_SOURCES}) + +cotire(libcommon) \ No newline at end of file diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt new file mode 100644 index 0000000..a9c1e21 --- /dev/null +++ b/src/game/CMakeLists.txt @@ -0,0 +1,8 @@ + +add_subdirectory(Oblivion) +add_subdirectory(Skyrim) +add_subdirectory(FalloutNewVegas) + + +add_library(libgame STATIC game.cpp) +target_link_libraries(libgame libgame_oblivion libgame_skyrim libgame_falloutnv) diff --git a/src/game/FalloutNewVegas/CMakeLists.txt b/src/game/FalloutNewVegas/CMakeLists.txt new file mode 100644 index 0000000..39b7930 --- /dev/null +++ b/src/game/FalloutNewVegas/CMakeLists.txt @@ -0,0 +1,31 @@ + +# Include source and library directories. +# include_directories (${CBASH_INCLUDE} +# ${Boost_INCLUDE_DIRS} +# ${ZLIB_INCLUDE_DIR}) + + +file (GLOB_RECURSE FALLOUTNV_RECORD_HEADERS "Records/*.h" ) +file (GLOB_RECURSE FALLOUTNV_RECORD_SOURCES "Records/*.cpp" ) +file (GLOB_RECURSE FALLOUTNV_RECORD_API "Records/API/*.cpp" ) + +set (FALLOUTNV_HEADERS + + "GRUPRecord.h" + "FNVFile.h" + "FNVRecord.h" + ${FALLOUTNV_RECORD_HEADERS} + ) + +set (FALLOUTNV_SOURCES + + "FNVFile.cpp" + "FNVRecord.cpp" + ${FALLOUTNV_RECORD_SOURCES} + ${FALLOUTNV_RECORD_API} + ) + +add_library(libgame_falloutnv STATIC ${FALLOUTNV_HEADERS} ${FALLOUTNV_SOURCES}) +target_link_libraries (libgame_falloutnv ${Boost_LIBRARIES} ${CBASH_LIBS} libcommon) + +cotire(libgame_falloutnv) diff --git a/src/game/Oblivion/CMakeLists.txt b/src/game/Oblivion/CMakeLists.txt new file mode 100644 index 0000000..9f1f7e8 --- /dev/null +++ b/src/game/Oblivion/CMakeLists.txt @@ -0,0 +1,30 @@ + +# Include source and library directories. +# include_directories (${CBASH_INCLUDE} +# ${Boost_INCLUDE_DIRS} +# ${ZLIB_INCLUDE_DIR}) + + +file (GLOB_RECURSE OBLIVION_RECORD_HEADERS "Records/*.h" ) +file (GLOB_RECURSE OBLIVION_RECORD_SOURCES "Records/*.cpp" ) +file (GLOB_RECURSE OBLIVION_RECORD_API "Records/API/*.cpp" ) + +set (OBLIVION_HEADERS + + "GRUPRecord.h" + "TES4File.h" + ${OBLIVION_RECORD_HEADERS} + ) + +set (OBLIVION_SOURCES + + "TES4File.cpp" + ${OBLIVION_RECORD_SOURCES} + ${OBLIVION_RECORD_API} + ) + + +add_library(libgame_oblivion STATIC ${OBLIVION_HEADERS} ${OBLIVION_SOURCES}) +target_link_libraries (libgame_oblivion ${Boost_LIBRARIES} ${CBASH_LIBS} libcommon) + +cotire(libgame_oblivion) diff --git a/src/game/Skyrim/CMakeLists.txt b/src/game/Skyrim/CMakeLists.txt new file mode 100644 index 0000000..8682727 --- /dev/null +++ b/src/game/Skyrim/CMakeLists.txt @@ -0,0 +1,44 @@ + +# Include source and library directories. +# include_directories (${CBASH_INCLUDE} +# ${Boost_INCLUDE_DIRS} +# ${ZLIB_INCLUDE_DIR}) + + +file (GLOB SKYRIM_RECORD_HEADERS "Records/*.h" ) +file (GLOB SKYRIM_RECORD_SOURCES "Records/*.cpp" ) + +file (GLOB_RECURSE SKYRIM_VMAD_HEADERS "VMAD/*.h" ) +file (GLOB_RECURSE SKYRIM_VMAD_SOURCES "VMAD/*.cpp" ) + +file (GLOB SKYRIM_RECORD_API "Records/API/*.cpp" ) + +set (SKYRIM_HEADERS + + "GRUPRecord.h" + "SkyrimCommon.h" + "SkyrimChunks.h" + "TES5ModFile.h" + "TES5Record.h" + "TES5File.h" + + ${SKYRIM_VMAD_HEADERS} + ${SKYRIM_RECORD_HEADERS} + ) + +set (SKYRIM_SOURCES + + "SkyrimChunks.cpp" + "SkyrimCommon.cpp" + "TES5File.cpp" + "TES5Record.cpp" + + ${SKYRIM_VMAD_SOURCES} + ${SKYRIM_RECORD_SOURCES} + ${SKYRIM_RECORD_API} + ) + +add_library(libgame_skyrim STATIC ${SKYRIM_HEADERS} ${SKYRIM_SOURCES}) +target_link_libraries (libgame_skyrim ${Boost_LIBRARIES} ${CBASH_LIBS} libcommon) + +cotire(libgame_skyrim) diff --git a/src/game/game.cpp b/src/game/game.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt new file mode 100644 index 0000000..4573262 --- /dev/null +++ b/src/main/CMakeLists.txt @@ -0,0 +1,37 @@ +# Settings passed on the command line: +# +# CBash_BUILD_SHARED_LIBS +# CBash_USE_STATIC_RUNTIME +# CBash_NO_BOOST_ZLIB + +############################## +# General Settings +############################## + + + +set(CBASH_HEADERS + "Collection.h" + "Visitors.h" + ) + +set (CBASH_SOURCES + "Collection.cpp" + "Visitors.cpp" + ) + +############################## +# Actual Building +############################## + +include_directories ( + ${CBASH_SOURCE}/game + ) + +# Build CBash. +add_library (libmain STATIC ${CBASH_HEADERS} ${CBASH_SOURCES}) +target_link_libraries (libmain libcommon libgame) + + +cotire(libmain) +