Skip to content

Commit 95c3d47

Browse files
committed
fix stupid cmake mistakes
1 parent f245a81 commit 95c3d47

File tree

1 file changed

+35
-41
lines changed

1 file changed

+35
-41
lines changed

CMakeLists.txt

+35-41
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,52 @@ set(${out_lib_name} "lib${component}.a" PARENT_SCOPE)
99
endif()
1010
endfunction()
1111

12-
function(select_lib output_lib lib_list configuration)
13-
list(LENGTH lib_list LIB_LEN )
14-
if(LIB_LEN GREATER 1)
15-
set(LIB_MET OFF)
16-
foreach(lib_i ${lib_list})
17-
if(LIB_MET)
18-
set(${output_lib} ${lib_i} PARENT_SCOPE)
19-
return()
20-
endif()
21-
if(NOT lib_i MATCHES ".*[Bb]oost.*" )
22-
if(lib_i STREQUAL "debug" )
23-
if(configuration STREQUAL "Debug")
24-
set(${LIB_MET} ON)
25-
endif()
26-
else()
27-
if(configuration STREQUAL "Release")
28-
set(${LIB_MET} ON)
29-
endif()
30-
endif()
31-
endif()
32-
endforeach(lib_i)
33-
else()
34-
set(${output_lib} ${lib_list} PARENT_SCOPE)
35-
endif()
36-
endfunction()
37-
38-
function(install_libs configuration lib_dir)
12+
function(install_debug_libs lib_dir)
13+
get_lib_name(renamed_system "boost_system")
14+
install(FILES ${Boost_SYSTEM_LIBRARY_DEBUG}
15+
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_system}
16+
)
17+
get_lib_name(renamed_date_time "boost_date_time")
18+
install(FILES ${Boost_DATE_TIME_LIBRARY_DEBUG}
19+
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_date_time}
20+
)
21+
get_lib_name(renamed_random "boost_random")
22+
install(FILES ${Boost_RANDOM_LIBRARY_DEBUG}
23+
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_random}
24+
)
3925

26+
install(TARGETS sioclient
27+
CONFIGURATIONS "Debug" DESTINATION ${lib_dir}
28+
)
29+
endfunction()
4030

31+
function(install_release_libs lib_dir)
4132
get_lib_name(renamed_system "boost_system")
42-
select_lib(src_lib_x ${Boost_SYSTEM_LIBRARY} ${configuration} )
43-
install(FILES ${src_lib_x}
44-
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_system}
33+
install(FILES ${Boost_SYSTEM_LIBRARY_RELEASE}
34+
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_system}
4535
)
4636
get_lib_name(renamed_date_time "boost_date_time")
47-
select_lib(src_lib_y ${Boost_SYSTEM_LIBRARY} ${configuration} )
48-
install(FILES ${src_lib_y}
49-
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_date_time}
37+
install(FILES ${Boost_DATE_TIME_LIBRARY_RELEASE}
38+
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_date_time}
5039
)
5140
get_lib_name(renamed_random "boost_random")
52-
select_lib(src_lib_z ${Boost_SYSTEM_LIBRARY} ${configuration} )
53-
install(FILES ${src_lib_z}
54-
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_random}
41+
install(FILES ${Boost_RANDOM_LIBRARY_RELEASE}
42+
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_random}
5543
)
5644

5745
install(TARGETS sioclient
58-
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir}
46+
CONFIGURATIONS "Release" DESTINATION ${lib_dir}
5947
)
6048
endfunction()
6149

50+
6251
MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
6352
if(NOT CMAKE_BUILD_TYPE )
6453
MESSAGE(STATUS "not define build type, set to release" )
6554
set(CMAKE_BUILD_TYPE Release )
55+
elseif(NOT (${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug" ))
56+
MESSAGE(SEND_ERROR "CMAKE_BUILD_TYPE must be either Release or Debug")
57+
return()
6658
endif()
6759

6860
set(BOOST_VER "1.55.0" CACHE STRING "boost version" )
@@ -110,7 +102,9 @@ target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
110102
install(FILES ${ALL_HEADERS}
111103
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/include"
112104
)
113-
set(LIB_DIR_DEBUG "${CMAKE_CURRENT_LIST_DIR}/build/lib/debug")
114-
set(LIB_DIR_RELEASE "${CMAKE_CURRENT_LIST_DIR}/build/lib/release")
115-
install_libs(Debug ${LIB_DIR_DEBUG})
116-
install_libs(Release ${LIB_DIR_RELEASE})
105+
106+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
107+
install_debug_libs("${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}" )
108+
else()
109+
install_release_libs("${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}" )
110+
endif()

0 commit comments

Comments
 (0)