CMakeLists.txt 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 3.8)
  2. project(LotRO_dat_library)
  3. set(CMAKE_CXX_STANDARD 11)
  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}" )
  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/Yaml)
  16. include_directories(${CMAKE_SOURCE_DIR}/Third-party/SQLite)
  17. include_directories(${CMAKE_SOURCE_DIR}/Third-party/Zlib)
  18. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_OUTPUT_DIR})
  19. SET(LIBRARY_OUTPUT_PATH ${CMAKE_OUTPUT_DIR})
  20. set(SOURCE_FILES
  21. ${CMAKE_SOURCE_DIR}/src/DatFile.cpp
  22. ${CMAKE_SOURCE_DIR}/src/BinaryData.cpp
  23. ${CMAKE_SOURCE_DIR}/src/Database.cpp
  24. ${CMAKE_SOURCE_DIR}/src/Subfile.cpp
  25. ${CMAKE_SOURCE_DIR}/src/SubDirectory.cpp
  26. ${CMAKE_SOURCE_DIR}/Third-party/SQLite/sqlite3.c
  27. ${CMAKE_SOURCE_DIR}/src/Subfiles/TextSubfile.cpp
  28. ${CMAKE_SOURCE_DIR}/src/Subfiles/JpgSubfile.cpp
  29. ${CMAKE_SOURCE_DIR}/src/Subfiles/DdsSubfile.cpp
  30. ${CMAKE_SOURCE_DIR}/src/Subfiles/OggSubfile.cpp
  31. ${CMAKE_SOURCE_DIR}/src/Subfiles/FontSubfile.cpp
  32. ${CMAKE_SOURCE_DIR}/src/Subfiles/WavSubfile.cpp
  33. ${CMAKE_SOURCE_DIR}/src/Subfiles/UnknownSubfile.cpp
  34. )
  35. set(CompilerFlags
  36. CMAKE_CXX_FLAGS
  37. CMAKE_CXX_FLAGS_DEBUG
  38. CMAKE_CXX_FLAGS_RELEASE
  39. CMAKE_CXX_FLAGS_MINSIZEREL
  40. CMAKE_CXX_FLAGS_RELWITHDEBINFO
  41. CMAKE_C_FLAGS
  42. CMAKE_C_FLAGS_DEBUG
  43. CMAKE_C_FLAGS_RELEASE
  44. CMAKE_C_FLAGS_MINSIZEREL
  45. CMAKE_C_FLAGS_RELWITHDEBINFO
  46. )
  47. foreach(CompilerFlag ${CompilerFlags})
  48. string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
  49. endforeach()
  50. # STATIC LIBRARY
  51. add_library(LotroDat_static STATIC ${SOURCE_FILES})
  52. # SHARED LIBRARY
  53. add_library(LotroDat SHARED ${SOURCE_FILES})
  54. # CONSOLE EXTRACTOR TOOL
  55. add_executable(LotRO_dat_extract_tester ${SOURCE_FILES} ${CMAKE_SOURCE_DIR}/src/Examples/extractor_example.cpp)
  56. # CONSOLE PATCHER TOOL
  57. add_executable(LotRO_dat_pat_tester ${SOURCE_FILES} ${CMAKE_SOURCE_DIR}/src/Examples/patcher_example.cpp)
  58. foreach(TARGET LotroDat_static LotroDat LotRO_dat_extract_tester LotRO_dat_pat_tester)
  59. if(MSVC)
  60. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third-Party/Zlib/zlibstatic.lib)
  61. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third-Party/Yaml/libyaml-cppmt.lib)
  62. target_link_libraries(${TARGET} vcruntime.lib MSVCRT.lib)
  63. else(MSVC)
  64. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third-Party/Zlib/libzlibstatic.a)
  65. target_link_libraries(${TARGET} ${CMAKE_SOURCE_DIR}/Third-Party/Yaml/libyaml-cpp.a)
  66. target_link_libraries(${TARGET} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic)
  67. endif(MSVC)
  68. endforeach(TARGET LotroDat_static LotroDat LotRO_dat_extract_tester LotRO_dat_pat_tester)