build: Rewrite CMakeLists.txt using a static library

This commit is contained in:
Vsevolod Kremianskii 2020-10-10 15:00:01 +07:00
parent 7f9812c0bc
commit 9e10fa5943
10 changed files with 28 additions and 59 deletions

View file

@ -249,7 +249,6 @@ set(SOURCES
src/gui/control/panel.cpp
src/gui/control/scrollbar.cpp
src/gui/gui.cpp
src/main.cpp
src/net/client.cpp
src/net/connection.cpp
src/net/command.cpp
@ -318,53 +317,30 @@ set(SOURCES
src/script/util.cpp
src/script/variable.cpp)
add_executable(reone ${HEADERS} ${SOURCES})
target_compile_definitions(reone PRIVATE BOOST_BIND_GLOBAL_PLACEHOLDERS)
target_include_directories(reone SYSTEM PRIVATE ${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${MAD_INCLUDE_DIR})
target_link_libraries(reone PRIVATE ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} GLEW::GLEW ${OPENGL_LIBRARIES} ${MAD_LIBRARY})
add_library(libreone STATIC ${HEADERS} ${SOURCES})
target_compile_definitions(libreone PUBLIC BOOST_BIND_NO_PLACEHOLDERS)
target_include_directories(libreone SYSTEM PUBLIC ${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${MAD_INCLUDE_DIR})
target_link_libraries(libreone PUBLIC ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} GLEW::GLEW ${OPENGL_LIBRARIES} ${MAD_LIBRARY})
if(WIN32)
target_link_libraries(reone PRIVATE SDL2::SDL2 OpenAL::OpenAL)
target_link_libraries(libreone PUBLIC SDL2::SDL2 OpenAL::OpenAL)
else()
target_link_libraries(reone PRIVATE ${SDL2_LIBRARIES} ${OpenAL_LIBRARIES} Threads::Threads)
target_link_libraries(libreone PUBLIC ${SDL2_LIBRARIES} ${OpenAL_LIBRARIES} Threads::Threads)
endif()
if(USE_EXTERNAL_GLM)
target_include_directories(reone PRIVATE ${CMAKE_SOURCE_DIR}/external/glm)
target_include_directories(libreone PUBLIC ${CMAKE_SOURCE_DIR}/external/glm)
endif()
add_executable(reone ${HEADERS} src/main.cpp)
target_link_libraries(reone PRIVATE libreone)
if(BUILD_TOOLS)
set(TOOLS_HEADERS
src/core/debug.h
src/core/log.h
src/core/pathutil.h
src/core/types.h
src/resource/2dafile.h
src/resource/binfile.h
src/resource/collection/biffile.h
src/resource/collection/erffile.h
src/resource/collection/keyfile.h
src/resource/collection/rimfile.h
src/resource/gfffile.h
src/resource/tlkfile.h
src/resource/util.h
tools/program.h
tools/tools.h)
set(TOOLS_SOURCES
src/core/debug.cpp
src/core/log.cpp
src/core/pathutil.cpp
src/resource/2dafile.cpp
src/resource/binfile.cpp
src/resource/collection/biffile.cpp
src/resource/collection/erffile.cpp
src/resource/collection/keyfile.cpp
src/resource/collection/rimfile.cpp
src/resource/gfffile.cpp
src/resource/tlkfile.cpp
src/resource/util.cpp
tools/main.cpp
tools/2datool.cpp
tools/biftool.cpp
@ -376,14 +352,6 @@ if(BUILD_TOOLS)
tools/tlktool.cpp
tools/tools.cpp)
add_executable(reone-tools ${TOOLS_HEADERS} ${TOOLS_SOURCES})
target_compile_definitions(reone-tools PRIVATE BOOST_BIND_GLOBAL_PLACEHOLDERS)
target_include_directories(reone-tools SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(reone-tools PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(reone-tools PRIVATE ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY})
if(USE_EXTERNAL_GLM)
target_include_directories(reone-tools PRIVATE ${CMAKE_SOURCE_DIR}/external/glm)
endif()
add_executable(reone-tools ${HEADERS} ${TOOLS_HEADERS} ${TOOLS_SOURCES})
target_link_libraries(reone-tools PRIVATE libreone)
endif()

View file

@ -19,7 +19,7 @@
#include <boost/property_tree/json_parser.hpp>
#include "src/resource/2dafile.h"
#include "../src/resource/2dafile.h"
using namespace std;

View file

@ -20,9 +20,9 @@
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include "src/core/log.h"
#include "src/resource/collection/biffile.h"
#include "src/resource/util.h"
#include "../src/core/log.h"
#include "../src/resource/collection/biffile.h"
#include "../src/resource/util.h"
using namespace std;

View file

@ -19,9 +19,9 @@
#include <boost/format.hpp>
#include "src/core/log.h"
#include "src/resource/collection/erffile.h"
#include "src/resource/util.h"
#include "../src/core/log.h"
#include "../src/resource/collection/erffile.h"
#include "../src/resource/util.h"
using namespace std;

View file

@ -22,7 +22,7 @@
#include <boost/property_tree/json_parser.hpp>
#include "src/resource/gfffile.h"
#include "../src/resource/gfffile.h"
using namespace std;

View file

@ -19,7 +19,7 @@
#include <boost/format.hpp>
#include "src/core/log.h"
#include "../src/core/log.h"
using namespace reone::resource;

View file

@ -17,8 +17,9 @@
#include <stdexcept>
#include "../src/core/log.h"
#include "program.h"
#include "src/core/log.h"
using namespace std;

View file

@ -22,7 +22,7 @@
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include "src/core/pathutil.h"
#include "../src/core/pathutil.h"
using namespace std;

View file

@ -19,9 +19,9 @@
#include <boost/format.hpp>
#include "src/core/log.h"
#include "src/resource/collection/rimfile.h"
#include "src/resource/util.h"
#include "../src/core/log.h"
#include "../src/resource/collection/rimfile.h"
#include "../src/resource/util.h"
using namespace std;

View file

@ -24,7 +24,7 @@
#include <boost/filesystem/path.hpp>
#include <boost/property_tree/ptree.hpp>
#include "src/resource/collection/keyfile.h"
#include "../src/resource/collection/keyfile.h"
namespace reone {