Skip to content

Commit 4232941

Browse files
committed
add debug/release lib distribution in cmake
1 parent 9e630d4 commit 4232941

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

CMakeLists.txt

+34-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
22
PROJECT(sioclient)
33

4+
function(get_lib_name out_lib_name component)
5+
if(MSVC)
6+
set(${out_lib_name} "${component}.lib" PARENT_SCOPE)
7+
else()
8+
set(${out_lib_name} "lib${component}.a" PARENT_SCOPE)
9+
endif()
10+
endfunction()
11+
12+
13+
function(install_libs configuration lib_dir)
14+
get_lib_name(renamed_system "boost_system")
15+
install(FILES ${Boost_SYSTEM_LIBRARY}
16+
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_system}
17+
)
18+
get_lib_name(renamed_date_time "boost_date_time")
19+
install(FILES ${Boost_DATE_TIME_LIBRARY}
20+
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_date_time}
21+
)
22+
get_lib_name(renamed_random "boost_random")
23+
install(FILES ${Boost_RANDOM_LIBRARY}
24+
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_random}
25+
)
26+
27+
install(TARGETS sioclient
28+
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir}
29+
)
30+
endfunction()
31+
32+
MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
33+
434
set(BOOST_VER "1.55.0" CACHE STRING "boost version" )
535
set(BOOST_PATH "__boost__" CACHE STRING "boost root path" )
636

@@ -28,8 +58,6 @@ set(Boost_USE_MULTITHREADED ON)
2858
set(Boost_USE_STATIC_RUNTIME OFF)
2959
find_package(Boost ${BOOST_VER} REQUIRED COMPONENTS system date_time random)
3060

31-
MESSAGE(STATUS ${Boost_SYSTEM_LIBRARY} )
32-
MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
3361
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src ALL_SRC)
3462
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/internal ALL_SRC)
3563
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h )
@@ -48,8 +76,7 @@ target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
4876
install(FILES ${ALL_HEADERS}
4977
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/include"
5078
)
51-
install(FILES ${Boost_LIBRARIES} DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib")
52-
53-
install(TARGETS sioclient
54-
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib"
55-
)
79+
set(LIB_DIR_DEBUG "${CMAKE_CURRENT_LIST_DIR}/build/lib/debug")
80+
set(LIB_DIR_RELEASE "${CMAKE_CURRENT_LIST_DIR}/build/lib/release")
81+
install_libs(Debug ${LIB_DIR_DEBUG})
82+
install_libs(Release ${LIB_DIR_RELEASE})

examples/QT/SioChatDemo/SioChatDemo.pro

+17-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,23 @@ FORMS += mainwindow.ui \
2626

2727
CONFIG(debug, debug|release):DEFINES +=DEBUG=1
2828

29-
LIBS += -L$$PWD/../../../build/lib/ -lsioclient
30-
LIBS += -L$$PWD/../../../build/lib/ -lboost_system
31-
LIBS += -L$$PWD/../../../build/lib/ -lboost_date_time
32-
LIBS += -L$$PWD/../../../build/lib/ -lboost_random
3329

3430
INCLUDEPATH += $$PWD/../../../build/include
3531
DEPENDPATH += $$PWD/../../../build/lib
32+
33+
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/release/ -lsioclient
34+
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/debug/ -lsioclient
35+
else:unix: LIBS += -L$$PWD/../../../build/lib/ -lsioclient
36+
37+
38+
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/release/ -lboost_random
39+
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/debug/ -lboost_random
40+
else:unix: LIBS += -L$$PWD/../../../build/lib/ -lboost_random
41+
42+
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/release/ -lboost_system
43+
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/debug/ -lboost_system
44+
else:unix: LIBS += -L$$PWD/../../../build/lib/ -lboost_system
45+
46+
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/release/ -lboost_date_time
47+
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/debug/ -lboost_date_time
48+
else:unix: LIBS += -L$$PWD/../../../build/lib/ -lboost_date_time

examples/QT/SioChatDemo/mainwindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifdef WIN32
77
#define BIND_EVENT(IO,EV,FN) \
88
do{ \
9-
client::event_listener_aux l = FN;\
9+
socket::event_listener_aux l = FN;\
1010
IO->on(EV,l);\
1111
} while(0)
1212

0 commit comments

Comments
 (0)