CMakeLists.txt 3.1 KB

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