Skip to content

Commit

Permalink
cmake improve, adapt to support multi config (#345)
Browse files Browse the repository at this point in the history
* cmake, adapt IMPORTED_LOCATION to support multi config

* remove custom target property: CC_DEPEND_DLLS
  • Loading branch information
drelaptop authored Jan 21, 2019
1 parent cfa5c8d commit d569571
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 64 deletions.
3 changes: 2 additions & 1 deletion Box2D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ set_target_properties(${target_name} PROPERTIES
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
# need use absolutely path
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug/lib${lib_name}.lib"
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release/lib${lib_name}.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
3 changes: 2 additions & 1 deletion bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set_property(TARGET ${target_name} APPEND PROPERTY

if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug/lib${lib_name}.lib"
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release/lib${lib_name}.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
3 changes: 2 additions & 1 deletion chipmunk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set_target_properties(${target_name} PROPERTIES
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug-lib/lib${lib_name}.lib"
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release-lib/lib${lib_name}.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
18 changes: 1 addition & 17 deletions cmake/CocosExternalConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@
endif()
endif()

# part libs existed debug and release both type
string(TOLOWER ${CMAKE_BUILD_TYPE} _type_folder)
# Visual Studio 2017 default build type include "Debug Release MinSizRel RelWithDebInfo"
if(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
set(_type_folder "debug")
elseif(${CMAKE_BUILD_TYPE} STREQUAL "MinSizRel")
set(_type_folder "release")
endif()

# set platform specific path
set(_path_prefix ${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/)
if(IOS)
Expand All @@ -42,14 +33,7 @@ elseif(ANDROID)
set(platform_spec_path android/${ANDROID_ABI})
elseif(WINDOWS)
set(platform_name win32)
# win32/, win32/debug, win32/debug-lib
if(EXISTS ${_path_prefix}/win32/${_type_folder}-lib)
set(platform_spec_path win32/${_type_folder}-lib)
elseif(EXISTS ${_path_prefix}win32/${_type_folder})
set(platform_spec_path win32/${_type_folder})
else()
set(platform_spec_path win32)
endif()
set(platform_spec_path win32)
elseif(MACOSX)
set(platform_name mac)
set(platform_spec_path mac)
Expand Down
10 changes: 7 additions & 3 deletions curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
)

if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/lib${lib_name}.dll"
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.dll"
IMPORTED_IMPLIB "${platform_spec_path}/lib${lib_name}.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions lua/luajit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/lua51.dll"
IMPORTED_LOCATION "${platform_spec_path}/lua51.lib"
IMPORTED_LOCATION "${platform_spec_path}/lua51.dll"
IMPORTED_IMPLIB "${platform_spec_path}/lua51.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ include(../cmake/CocosExternalConfig.cmake)
macro(set_openssl_sub_target sub_lib_name)

set(sub_target_name ext_${sub_lib_name})
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${sub_target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${sub_target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
)
if(WINDOWS)
set_target_properties(${sub_target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/lib${sub_lib_name}-1_1.dll"
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}.lib"
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}-1_1.dll"
IMPORTED_IMPLIB "${platform_spec_path}/lib${sub_lib_name}.lib"
)
else()
set_target_properties(${sub_target_name} PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions spidermonkey/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/mozjs-33.dll"
IMPORTED_LOCATION "${platform_spec_path}/mozjs-33.lib"
IMPORTED_LOCATION "${platform_spec_path}/mozjs-33.dll"
IMPORTED_IMPLIB "${platform_spec_path}/mozjs-33.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions sqlite3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.lib"
)
endif()
10 changes: 7 additions & 3 deletions uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/${lib_name}.dll"
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}_a.lib"
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}.dll"
IMPORTED_IMPLIB "${platform_spec_path}/${lib_name}_a.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions websockets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
Expand All @@ -22,8 +26,8 @@ set_property(TARGET ${target_name} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "ext

if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/${lib_name}.dll"
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}.lib"
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}.dll"
IMPORTED_IMPLIB "${platform_spec_path}/${lib_name}.lib"
)
else()
set_target_properties(${target_name} PROPERTIES
Expand Down
6 changes: 3 additions & 3 deletions win32-specific/MP3Decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
add_library(${target_name} SHARED IMPORTED GLOBAL)

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libmpg123.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libmpg123.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libmpg123.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libmpg123.lib"
)
14 changes: 7 additions & 7 deletions win32-specific/OggDecoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
add_library(${target_name} SHARED IMPORTED GLOBAL)

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libogg.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libogg.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libogg.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libogg.lib"
)

# internal link depend
set_property(TARGET ${target_name} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbis.lib"
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbis.lib"
)
set_property(TARGET ${target_name} APPEND PROPERTY
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbis.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbis.dll"
)
set_property(TARGET ${target_name} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbisfile.lib"
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbisfile.lib"
)
set_property(TARGET ${target_name} APPEND PROPERTY
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbisfile.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libvorbisfile.dll"
)

7 changes: 3 additions & 4 deletions win32-specific/OpenalSoft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
add_library(${target_name} SHARED IMPORTED GLOBAL)

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# todo
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/OpenAL32.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/OpenAL32.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/OpenAL32.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/OpenAL32.lib"
)
6 changes: 3 additions & 3 deletions win32-specific/gles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
add_library(${target_name} SHARED IMPORTED GLOBAL)

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include/OGLES
)

set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/glew32.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/glew32.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/glew32.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/glew32.lib"
)
6 changes: 3 additions & 3 deletions win32-specific/icon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ project(${lib_name})

include(../../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
add_library(${target_name} SHARED IMPORTED GLOBAL)

set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/iconv.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libiconv.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/iconv.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/libiconv.lib"
)
10 changes: 7 additions & 3 deletions zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ project(${lib_name})

include(../cmake/CocosExternalConfig.cmake)

add_library(${target_name} STATIC IMPORTED GLOBAL)
if(WINDOWS)
add_library(${target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${target_name} STATIC IMPORTED GLOBAL)
endif()

if(MACOSX OR ANDROID)
set_target_properties(${target_name} PROPERTIES
Expand All @@ -21,8 +25,8 @@ elseif(WINDOWS)
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32-specific/zlib/include"
)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/../win32-specific/zlib/prebuilt/zlib1.dll"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../win32-specific/zlib/prebuilt/libzlib.lib"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../win32-specific/zlib/prebuilt/zlib1.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../win32-specific/zlib/prebuilt/libzlib.lib"
)
endif()

0 comments on commit d569571

Please sign in to comment.