Help Linking static libs on Windows

Hi. I'm fairly new to c++, and very new to building software on windows. I've finally gotten my project to build on windows, using CMake and MinGWw64. My project currently consists of two parts: A Shared lib, and a single test executable.

However, my end result is certainly less than optimal. The directory for each test executable needs to look like this to run:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
soko/
    libboost_filesystem-mgw48-d-1_55.dll
    libboost_system-mgw48-d-1_55.dll
    libgcc_s_sjlj-1.dll
    libsqee.dll
    libstdc++-6.dll
    libwinpthread-1.dll
    sfgui.dll
    sfml-audio-2.dll
    sfml-graphics-2.dll
    sfml-network-2.dll
    sfml-system-2.dll
    sfml-window-2.dll
    soko.exe


Of these, the only ones I want to actually be dlls are sfgui, sfml-*, and libsqee. But I can't work out how to statically link any of the others into libsqee. My /CmakeLists.txt file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
project(SQEE)
cmake_minimum_required(VERSION 2.8)

set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build/lib")

set(SRCDIR "${PROJECT_SOURCE_DIR}/src")
set(INCDIR "${PROJECT_SOURCE_DIR}/include")

set(SOURCES
    "${SRCDIR}/libsqee/application.cpp"
    "${SRCDIR}/libsqee/handler.cpp"
    "${SRCDIR}/libsqee/extra/handlers.cpp"
    "${SRCDIR}/libsqee/entity.cpp"
    "${SRCDIR}/libsqee/scene.cpp"
    "${SRCDIR}/libsqee/textureholder.cpp"
    "${SRCDIR}/libsqee/extra/helpers.cpp"
    "${INCDIR}/libsqee/application.hpp"
    "${INCDIR}/libsqee/handler.hpp"
    "${INCDIR}/libsqee/extra/handlers.hpp"
    "${INCDIR}/libsqee/entity.hpp"
    "${INCDIR}/libsqee/scene.hpp"
    "${INCDIR}/libsqee/textureholder.hpp"
    "${INCDIR}/libsqee/extra/helpers.hpp"
    "${INCDIR}/libsqee/base.hpp"
    "${INCDIR}/libsqee/extra.hpp"
)

add_library(libsqee SHARED ${SOURCES})
link_libraries(sfml-window sfml-graphics sfml-system sfgui jsoncpp boost_filesystem boost_system)
include_directories("${PROJECT_SOURCE_DIR}/include/libsqee")
set_target_properties(libsqee PROPERTIES PREFIX "")

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    include_directories("${PROJECT_SOURCE_DIR}/extlibs/include")
    FIND_LIBRARY(SFML_SYSTEM_LIB sfml-system "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFML_GRAPHICS_LIB sfml-graphics "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFML_WINDOW_LIB sfml-window "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFGUI_LIB sfgui "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(JSONCPP_LIB jsoncpp "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(BOOST_SYSTEM_LIB boost_system "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(BOOST_FILESYSTEM_LIB boost_filesystem "${PROJECT_SOURCE_DIR}/extlibs/lib")
    TARGET_LINK_LIBRARIES(libsqee ${SFML_SYSTEM_LIB} ${SFML_GRAPHICS_LIB} ${SFML_WINDOW_LIB} ${SFGUI_LIB} ${JSONCPP_LIB} ${BOOST_SYSTEM_LIB} ${BOOST_FILESYSTEM_LIB})
endif()
	
add_subdirectory("tests/soko")


and /tests/soko/CMakeLists.txt:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build/tests/soko")

set(SOURCES
    "main.cpp"
    "helpers.hpp"
    "app.cpp"             "app.hpp"
    "level.cpp"           "level.hpp"
    "scenehud.cpp"        "scenehud.hpp"
    "scenemain.cpp"       "scenemain.hpp"
    "scenemainmenu.cpp"   "scenemainmenu.hpp"
    "handlermainmenu.cpp" "handlermainmenu.hpp"
)

add_executable(soko ${SOURCES})
target_link_libraries(soko libsqee)
include_directories("${PROJECT_SOURCE_DIR}/include")

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    include_directories("${PROJECT_SOURCE_DIR}/extlibs/include")
    FIND_LIBRARY(SFML_SYSTEM_LIB sfml-system "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFML_GRAPHICS_LIB sfml-graphics "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFML_WINDOW_LIB sfml-window "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(SFGUI_LIB sfgui "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(JSONCPP_LIB jsoncpp "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(BOOST_SYSTEM_LIB boost_system "${PROJECT_SOURCE_DIR}/extlibs/lib")
    FIND_LIBRARY(BOOST_FILESYSTEM_LIB boost_filesystem "${PROJECT_SOURCE_DIR}/extlibs/lib")
    TARGET_LINK_LIBRARIES(soko ${SFML_SYSTEM_LIB} ${SFML_GRAPHICS_LIB} ${SFML_WINDOW_LIB} ${SFGUI_LIB} ${JSONCPP_LIB} ${BOOST_SYSTEM_LIB} ${BOOST_FILESYSTEM_LIB})
endif()

add_custom_command(TARGET soko COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/build/tests/soko/res")
file(GLOB RESOURCES "res/*.*")
foreach(res ${RESOURCES})
    add_custom_command(TARGET soko COMMAND ${CMAKE_COMMAND} -E copy ${res} "${CMAKE_BINARY_DIR}/build/tests/soko/res")
endforeach()

add_custom_command(TARGET soko COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/build/tests/soko/res/levels")
file(GLOB RESOURCES "res/levels/*.json")
foreach(res ${RESOURCES})
    add_custom_command(TARGET soko COMMAND ${CMAKE_COMMAND} -E copy ${res} "${CMAKE_BINARY_DIR}/build/tests/soko/res/levels")
endforeach()


Does anyone here have any ideas as to how I could go about tidying this up?
Last edited on
Topic archived. No new replies allowed.