CMakeLists.txt 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. cmake_minimum_required(VERSION 3.8)
  2. project(LotRO_dat_library)
  3. set(CMAKE_CXX_STANDARD 14)
  4. set(PROJECT_BINARY_DIR bin)
  5. set(PROJECT_VERSION 0.1.0)
  6. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -O2 -Wall -Wextra")
  7. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
  8. if (MSVS)
  9. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE} /MT /SAFESEH:NO")
  10. endif(MSVS)
  11. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
  12. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
  13. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
  14. include_directories(${CMAKE_SOURCE_DIR}/include)
  15. include_directories(${CMAKE_SOURCE_DIR}/Third_party)
  16. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_OUTPUT_DIR})
  17. SET(LIBRARY_OUTPUT_PATH ${CMAKE_OUTPUT_DIR})
  18. set(HEADER_FILES
  19. ${CMAKE_SOURCE_DIR}/include/BinaryData.h
  20. ${CMAKE_SOURCE_DIR}/include/Database.h
  21. ${CMAKE_SOURCE_DIR}/include/DatException.h
  22. ${CMAKE_SOURCE_DIR}/include/DatFile.h
  23. ${CMAKE_SOURCE_DIR}/include/LotroDat.h
  24. ${CMAKE_SOURCE_DIR}/include/SubDirectory.h
  25. ${CMAKE_SOURCE_DIR}/include/Subfile.h
  26. ${CMAKE_SOURCE_DIR}/include/SubfileData.h
  27. )
  28. set(SOURCE_FILES
  29. ${CMAKE_SOURCE_DIR}/src/DatFile.cpp
  30. ${CMAKE_SOURCE_DIR}/src/BinaryData.cpp
  31. ${CMAKE_SOURCE_DIR}/src/Database.cpp
  32. ${CMAKE_SOURCE_DIR}/src/Subfile.cpp
  33. ${CMAKE_SOURCE_DIR}/src/SubDirectory.cpp
  34. ${CMAKE_SOURCE_DIR}/src/Subfiles/TextSubfile.cpp
  35. ${CMAKE_SOURCE_DIR}/src/Subfiles/JpgSubfile.cpp
  36. ${CMAKE_SOURCE_DIR}/src/Subfiles/DdsSubfile.cpp
  37. ${CMAKE_SOURCE_DIR}/src/Subfiles/OggSubfile.cpp
  38. ${CMAKE_SOURCE_DIR}/src/Subfiles/FontSubfile.cpp
  39. ${CMAKE_SOURCE_DIR}/src/Subfiles/WavSubfile.cpp
  40. ${CMAKE_SOURCE_DIR}/src/Subfiles/UnknownSubfile.cpp
  41. ${CMAKE_SOURCE_DIR}/Third_party/SQLite/sqlite3.c
  42. ${CMAKE_SOURCE_DIR}/Third_party/EasyLogging++/easylogging++.cc
  43. )
  44. set(CompilerFlags
  45. CMAKE_CXX_FLAGS
  46. CMAKE_CXX_FLAGS_DEBUG
  47. CMAKE_CXX_FLAGS_RELEASE
  48. CMAKE_CXX_FLAGS_MINSIZEREL
  49. CMAKE_CXX_FLAGS_RELWITHDEBINFO
  50. CMAKE_C_FLAGS
  51. CMAKE_C_FLAGS_DEBUG
  52. CMAKE_C_FLAGS_RELEASE
  53. CMAKE_C_FLAGS_MINSIZEREL
  54. CMAKE_C_FLAGS_RELWITHDEBINFO
  55. )
  56. foreach(CompilerFlag ${CompilerFlags})
  57. string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
  58. endforeach()
  59. # STATIC LIBRARY
  60. add_library(LotroDat_static STATIC ${SOURCE_FILES} ${HEADER_FILES})
  61. # SHARED LIBRARY
  62. add_library(LotroDat SHARED ${SOURCE_FILES} ${HEADER_FILES})
  63. # CONSOLE EXTRACTOR TOOL
  64. add_executable(LotRO_dat_extractor ${SOURCE_FILES} ${HEADER_FILES} ${CMAKE_SOURCE_DIR}/src/Examples/extractor_example.cpp)
  65. # CONSOLE PATCHER TOOL
  66. add_executable(LotRO_dat_patcher ${SOURCE_FILES} ${HEADER_FILES} ${CMAKE_SOURCE_DIR}/src/Examples/patcher_example.cpp)
  67. foreach(TARGET LotroDat_static LotroDat LotRO_dat_extractor LotRO_dat_patcher)
  68. #if(MSVC)
  69. # target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third_Party/Zlib/zlibstatic.lib)
  70. # target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third_Party/Yaml-cpp/libyaml-cppmt.lib)
  71. # target_link_libraries(${TARGET} vcruntime.lib MSVCRT.lib)
  72. #else(MSVC)
  73. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third_Party/lib/libzlibstatic.a)
  74. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third_Party/lib/libyaml-cpp.a)
  75. target_link_libraries(${TARGET} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic)
  76. #endif(MSVC)
  77. endforeach(TARGET LotroDat_static LotroDat LotRO_dat_extractor LotRO_dat_patcher)