Skip to content

Commit 4c545e3

Browse files
authored
cmake improve, adapt to support multi config (#345) (#346)
* cmake, adapt IMPORTED_LOCATION to support multi config * remove custom target property: CC_DEPEND_DLLS
1 parent af674ed commit 4c545e3

File tree

17 files changed

+82
-64
lines changed

17 files changed

+82
-64
lines changed

Box2D/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ set_target_properties(${target_name} PROPERTIES
1616
if(WINDOWS)
1717
set_target_properties(${target_name} PROPERTIES
1818
# need use absolutely path
19-
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
19+
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug/lib${lib_name}.lib"
20+
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release/lib${lib_name}.lib"
2021
)
2122
else()
2223
set_target_properties(${target_name} PROPERTIES

bullet/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ set_property(TARGET ${target_name} APPEND PROPERTY
1818

1919
if(WINDOWS)
2020
set_target_properties(${target_name} PROPERTIES
21-
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
21+
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug/lib${lib_name}.lib"
22+
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release/lib${lib_name}.lib"
2223
)
2324
else()
2425
set_target_properties(${target_name} PROPERTIES

chipmunk/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ set_target_properties(${target_name} PROPERTIES
1414
)
1515
if(WINDOWS)
1616
set_target_properties(${target_name} PROPERTIES
17-
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
17+
IMPORTED_LOCATION_DEBUG "${platform_spec_path}/debug-lib/lib${lib_name}.lib"
18+
IMPORTED_LOCATION_RELEASE "${platform_spec_path}/release-lib/lib${lib_name}.lib"
1819
)
1920
else()
2021
set_target_properties(${target_name} PROPERTIES

cmake/CocosExternalConfig.cmake

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
endif()
2424
endif()
2525

26-
# part libs existed debug and release both type
27-
string(TOLOWER ${CMAKE_BUILD_TYPE} _type_folder)
28-
# Visual Studio 2017 default build type include "Debug Release MinSizRel RelWithDebInfo"
29-
if(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
30-
set(_type_folder "debug")
31-
elseif(${CMAKE_BUILD_TYPE} STREQUAL "MinSizRel")
32-
set(_type_folder "release")
33-
endif()
34-
3526
# set platform specific path
3627
set(_path_prefix ${CMAKE_CURRENT_SOURCE_DIR}/prebuilt/)
3728
if(IOS)
@@ -42,14 +33,7 @@ elseif(ANDROID)
4233
set(platform_spec_path android/${ANDROID_ABI})
4334
elseif(WINDOWS)
4435
set(platform_name win32)
45-
# win32/, win32/debug, win32/debug-lib
46-
if(EXISTS ${_path_prefix}/win32/${_type_folder}-lib)
47-
set(platform_spec_path win32/${_type_folder}-lib)
48-
elseif(EXISTS ${_path_prefix}win32/${_type_folder})
49-
set(platform_spec_path win32/${_type_folder})
50-
else()
51-
set(platform_spec_path win32)
52-
endif()
36+
set(platform_spec_path win32)
5337
elseif(MACOSX)
5438
set(platform_name mac)
5539
set(platform_spec_path mac)

curl/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ project(${lib_name})
77

88
include(../cmake/CocosExternalConfig.cmake)
99

10-
add_library(${target_name} STATIC IMPORTED GLOBAL)
10+
if(WINDOWS)
11+
add_library(${target_name} SHARED IMPORTED GLOBAL)
12+
else()
13+
add_library(${target_name} STATIC IMPORTED GLOBAL)
14+
endif()
1115

1216
set_target_properties(${target_name} PROPERTIES
1317
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
1418
)
1519

1620
if(WINDOWS)
1721
set_target_properties(${target_name} PROPERTIES
18-
CC_DEPEND_DLLS "${platform_spec_path}/lib${lib_name}.dll"
19-
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
22+
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.dll"
23+
IMPORTED_IMPLIB "${platform_spec_path}/lib${lib_name}.lib"
2024
)
2125
else()
2226
set_target_properties(${target_name} PROPERTIES

lua/luajit/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ project(${lib_name})
66

77
include(../../cmake/CocosExternalConfig.cmake)
88

9-
add_library(${target_name} STATIC IMPORTED GLOBAL)
9+
if(WINDOWS)
10+
add_library(${target_name} SHARED IMPORTED GLOBAL)
11+
else()
12+
add_library(${target_name} STATIC IMPORTED GLOBAL)
13+
endif()
1014

1115
set_target_properties(${target_name} PROPERTIES
1216
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
1317
)
1418
if(WINDOWS)
1519
set_target_properties(${target_name} PROPERTIES
16-
CC_DEPEND_DLLS "${platform_spec_path}/lua51.dll"
17-
IMPORTED_LOCATION "${platform_spec_path}/lua51.lib"
20+
IMPORTED_LOCATION "${platform_spec_path}/lua51.dll"
21+
IMPORTED_IMPLIB "${platform_spec_path}/lua51.lib"
1822
)
1923
else()
2024
set_target_properties(${target_name} PROPERTIES

openssl/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ include(../cmake/CocosExternalConfig.cmake)
1010
macro(set_openssl_sub_target sub_lib_name)
1111

1212
set(sub_target_name ext_${sub_lib_name})
13-
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
13+
if(WINDOWS)
14+
add_library(${sub_target_name} SHARED IMPORTED GLOBAL)
15+
else()
16+
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
17+
endif()
1418

1519
set_target_properties(${sub_target_name} PROPERTIES
1620
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
1721
)
1822
if(WINDOWS)
1923
set_target_properties(${sub_target_name} PROPERTIES
20-
CC_DEPEND_DLLS "${platform_spec_path}/lib${sub_lib_name}-1_1.dll"
21-
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}.lib"
24+
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}-1_1.dll"
25+
IMPORTED_IMPLIB "${platform_spec_path}/lib${sub_lib_name}.lib"
2226
)
2327
else()
2428
set_target_properties(${sub_target_name} PROPERTIES

spidermonkey/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ project(${lib_name})
77

88
include(../cmake/CocosExternalConfig.cmake)
99

10-
add_library(${target_name} STATIC IMPORTED GLOBAL)
10+
if(WINDOWS)
11+
add_library(${target_name} SHARED IMPORTED GLOBAL)
12+
else()
13+
add_library(${target_name} STATIC IMPORTED GLOBAL)
14+
endif()
1115

1216
set_target_properties(${target_name} PROPERTIES
1317
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
1418
)
1519
if(WINDOWS)
1620
set_target_properties(${target_name} PROPERTIES
17-
CC_DEPEND_DLLS "${platform_spec_path}/mozjs-33.dll"
18-
IMPORTED_LOCATION "${platform_spec_path}/mozjs-33.lib"
21+
IMPORTED_LOCATION "${platform_spec_path}/mozjs-33.dll"
22+
IMPORTED_IMPLIB "${platform_spec_path}/mozjs-33.lib"
1923
)
2024
else()
2125
set_target_properties(${target_name} PROPERTIES

sqlite3/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ project(${lib_name})
77

88
include(../cmake/CocosExternalConfig.cmake)
99

10-
add_library(${target_name} STATIC IMPORTED GLOBAL)
10+
if(WINDOWS)
11+
add_library(${target_name} SHARED IMPORTED GLOBAL)
12+
else()
13+
add_library(${target_name} STATIC IMPORTED GLOBAL)
14+
endif()
1115

1216
set_target_properties(${target_name} PROPERTIES
1317
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
1418
)
1519
if(WINDOWS)
1620
set_target_properties(${target_name} PROPERTIES
17-
CC_DEPEND_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.dll"
18-
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.lib"
21+
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.dll"
22+
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${platform_name}/${lib_name}.lib"
1923
)
2024
endif()

uv/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ project(${lib_name})
77

88
include(../cmake/CocosExternalConfig.cmake)
99

10-
add_library(${target_name} STATIC IMPORTED GLOBAL)
10+
if(WINDOWS)
11+
add_library(${target_name} SHARED IMPORTED GLOBAL)
12+
else()
13+
add_library(${target_name} STATIC IMPORTED GLOBAL)
14+
endif()
1115

1216
set_target_properties(${target_name} PROPERTIES
1317
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
1418
)
1519
if(WINDOWS)
1620
set_target_properties(${target_name} PROPERTIES
17-
CC_DEPEND_DLLS "${platform_spec_path}/${lib_name}.dll"
18-
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}_a.lib"
21+
IMPORTED_LOCATION "${platform_spec_path}/${lib_name}.dll"
22+
IMPORTED_IMPLIB "${platform_spec_path}/${lib_name}_a.lib"
1923
)
2024
else()
2125
set_target_properties(${target_name} PROPERTIES

0 commit comments

Comments
 (0)