Skip to content

Commit

Permalink
fix stupid cmake mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
melode11 committed Apr 15, 2015
1 parent f245a81 commit 95c3d47
Showing 1 changed file with 35 additions and 41 deletions.
76 changes: 35 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,52 @@ set(${out_lib_name} "lib${component}.a" PARENT_SCOPE)
endif()
endfunction()

function(select_lib output_lib lib_list configuration)
list(LENGTH lib_list LIB_LEN )
if(LIB_LEN GREATER 1)
set(LIB_MET OFF)
foreach(lib_i ${lib_list})
if(LIB_MET)
set(${output_lib} ${lib_i} PARENT_SCOPE)
return()
endif()
if(NOT lib_i MATCHES ".*[Bb]oost.*" )
if(lib_i STREQUAL "debug" )
if(configuration STREQUAL "Debug")
set(${LIB_MET} ON)
endif()
else()
if(configuration STREQUAL "Release")
set(${LIB_MET} ON)
endif()
endif()
endif()
endforeach(lib_i)
else()
set(${output_lib} ${lib_list} PARENT_SCOPE)
endif()
endfunction()

function(install_libs configuration lib_dir)
function(install_debug_libs lib_dir)
get_lib_name(renamed_system "boost_system")
install(FILES ${Boost_SYSTEM_LIBRARY_DEBUG}
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_system}
)
get_lib_name(renamed_date_time "boost_date_time")
install(FILES ${Boost_DATE_TIME_LIBRARY_DEBUG}
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_date_time}
)
get_lib_name(renamed_random "boost_random")
install(FILES ${Boost_RANDOM_LIBRARY_DEBUG}
CONFIGURATIONS "Debug" DESTINATION ${lib_dir} RENAME ${renamed_random}
)

install(TARGETS sioclient
CONFIGURATIONS "Debug" DESTINATION ${lib_dir}
)
endfunction()

function(install_release_libs lib_dir)
get_lib_name(renamed_system "boost_system")
select_lib(src_lib_x ${Boost_SYSTEM_LIBRARY} ${configuration} )
install(FILES ${src_lib_x}
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_system}
install(FILES ${Boost_SYSTEM_LIBRARY_RELEASE}
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_system}
)
get_lib_name(renamed_date_time "boost_date_time")
select_lib(src_lib_y ${Boost_SYSTEM_LIBRARY} ${configuration} )
install(FILES ${src_lib_y}
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_date_time}
install(FILES ${Boost_DATE_TIME_LIBRARY_RELEASE}
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_date_time}
)
get_lib_name(renamed_random "boost_random")
select_lib(src_lib_z ${Boost_SYSTEM_LIBRARY} ${configuration} )
install(FILES ${src_lib_z}
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir} RENAME ${renamed_random}
install(FILES ${Boost_RANDOM_LIBRARY_RELEASE}
CONFIGURATIONS "Release" DESTINATION ${lib_dir} RENAME ${renamed_random}
)

install(TARGETS sioclient
CONFIGURATIONS ${configuration} DESTINATION ${lib_dir}
CONFIGURATIONS "Release" DESTINATION ${lib_dir}
)
endfunction()


MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
if(NOT CMAKE_BUILD_TYPE )
MESSAGE(STATUS "not define build type, set to release" )
set(CMAKE_BUILD_TYPE Release )
elseif(NOT (${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug" ))
MESSAGE(SEND_ERROR "CMAKE_BUILD_TYPE must be either Release or Debug")
return()
endif()

set(BOOST_VER "1.55.0" CACHE STRING "boost version" )
Expand Down Expand Up @@ -110,7 +102,9 @@ target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
install(FILES ${ALL_HEADERS}
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/include"
)
set(LIB_DIR_DEBUG "${CMAKE_CURRENT_LIST_DIR}/build/lib/debug")
set(LIB_DIR_RELEASE "${CMAKE_CURRENT_LIST_DIR}/build/lib/release")
install_libs(Debug ${LIB_DIR_DEBUG})
install_libs(Release ${LIB_DIR_RELEASE})

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install_debug_libs("${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}" )
else()
install_release_libs("${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}" )
endif()

0 comments on commit 95c3d47

Please sign in to comment.