forked from conan-io/conan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake_test.py
1660 lines (1420 loc) · 73 KB
/
cmake_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import platform
import shutil
import stat
import sys
import unittest
import mock
import six
from parameterized.parameterized import parameterized
import pytest
from conans.client import tools
from conans.client.build.cmake import CMake
from conans.client.build.cmake_flags import cmake_in_local_cache_var_name
from conans.client.conf import get_default_settings_yml
from conans.client.tools import cross_building
from conans.client.tools.oss import cpu_count, detected_architecture
from conans.errors import ConanException
from conans.model.build_info import CppInfo, DepsCppInfo
from conans.model.ref import ConanFileReference
from conans.model.settings import Settings
from conans.test.utils.mocks import MockSettings, ConanFileMock
from conans.test.utils.test_files import temp_folder
from conans.util.files import load, save
from conans.model.conf import ConfDefinition
def _format_path_as_cmake(pathstr):
if platform.system() == "Windows":
drive, path = os.path.splitdrive(pathstr)
return drive.upper() + path.replace(os.path.sep, "/")
return pathstr
class CMakeTest(unittest.TestCase):
def setUp(self):
self.tempdir = temp_folder(path_with_spaces=False)
self.tempdir2 = temp_folder(path_with_spaces=False)
def tearDown(self):
shutil.rmtree(self.tempdir)
shutil.rmtree(self.tempdir2)
def test_config_patch(self):
conanfile = ConanFileMock()
conanfile.name = "MyPkg"
conanfile.settings = Settings()
conanfile.source_folder = os.path.join(self.tempdir, "src")
conanfile.build_folder = os.path.join(self.tempdir, "build")
conanfile.package_folder = os.path.join(self.tempdir, "pkg")
conanfile.deps_cpp_info = DepsCppInfo()
msg = "FOLDER: " + _format_path_as_cmake(conanfile.package_folder)
for folder in (conanfile.build_folder, conanfile.package_folder):
save(os.path.join(folder, "file1.cmake"), "Nothing")
save(os.path.join(folder, "file2"), msg)
save(os.path.join(folder, "file3.txt"), msg)
save(os.path.join(folder, "file3.cmake"), msg)
save(os.path.join(folder, "sub", "file3.cmake"), msg)
cmake = CMake(conanfile, generator="Unix Makefiles")
cmake.patch_config_paths()
for folder in (conanfile.build_folder, conanfile.package_folder):
self.assertEqual("Nothing", load(os.path.join(folder, "file1.cmake")))
self.assertEqual(msg, load(os.path.join(folder, "file2")))
self.assertEqual(msg, load(os.path.join(folder, "file3.txt")))
self.assertEqual("FOLDER: ${CONAN_MYPKG_ROOT}",
load(os.path.join(folder, "file3.cmake")))
self.assertEqual("FOLDER: ${CONAN_MYPKG_ROOT}",
load(os.path.join(folder, "sub", "file3.cmake")))
def test_config_patch_deps(self):
conanfile = ConanFileMock()
conanfile.name = "MyPkg"
conanfile.settings = Settings()
conanfile.source_folder = os.path.join(self.tempdir, "src")
conanfile.build_folder = os.path.join(self.tempdir, "build")
conanfile.package_folder = os.path.join(self.tempdir, "pkg")
conanfile.deps_cpp_info = DepsCppInfo()
ref = ConanFileReference.loads("MyPkg1/0.1@user/channel")
cpp_info = CppInfo(ref.name, self.tempdir2)
conanfile.deps_cpp_info.add(ref.name, cpp_info)
self.tempdir = temp_folder(path_with_spaces=False)
self.assertEqual(list(conanfile.deps_cpp_info.deps), ['MyPkg1'])
self.assertEqual(conanfile.deps_cpp_info['MyPkg1'].rootpath,
self.tempdir2)
msg = "FOLDER: " + _format_path_as_cmake(self.tempdir2)
for folder in (conanfile.build_folder, conanfile.package_folder):
save(os.path.join(folder, "file1.cmake"), "Nothing")
save(os.path.join(folder, "file2"), msg)
save(os.path.join(folder, "file3.txt"), msg)
save(os.path.join(folder, "file3.cmake"), msg)
save(os.path.join(folder, "sub", "file3.cmake"), msg)
cmake = CMake(conanfile, generator="Unix Makefiles")
cmake.patch_config_paths()
for folder in (conanfile.build_folder, conanfile.package_folder):
self.assertEqual("Nothing", load(os.path.join(folder, "file1.cmake")))
self.assertEqual(msg, load(os.path.join(folder, "file2")))
self.assertEqual(msg, load(os.path.join(folder, "file3.txt")))
self.assertEqual("FOLDER: ${CONAN_MYPKG1_ROOT}",
load(os.path.join(folder, "file3.cmake")))
self.assertEqual("FOLDER: ${CONAN_MYPKG1_ROOT}",
load(os.path.join(folder, "sub", "file3.cmake")))
def test_partial_build(self):
conanfile = ConanFileMock()
conanfile.settings = Settings()
conanfile.should_configure = False
conanfile.should_build = False
conanfile.should_install = False
conanfile.should_test = False
cmake = CMake(conanfile, generator="Unix Makefiles")
cmake.configure()
self.assertIsNone(conanfile.command)
cmake.build()
self.assertIsNone(conanfile.command)
cmake.install()
self.assertIsNone(conanfile.command)
conanfile.name = None
cmake.patch_config_paths()
cmake.test()
self.assertIsNone(conanfile.command)
def test_should_flags(self):
conanfile = ConanFileMock()
conanfile.settings = Settings()
conanfile.should_configure = False
conanfile.should_build = True
conanfile.should_install = False
conanfile.should_test = True
conanfile.package_folder = temp_folder()
cmake = CMake(conanfile, generator="Unix Makefiles")
cmake.configure()
self.assertIsNone(conanfile.command)
cmake.build()
self.assertIn("cmake --build %s" %
CMakeTest.scape(". -- -j%i" % cpu_count(output=conanfile.output)),
conanfile.command)
cmake.install()
self.assertNotIn("cmake --build %s" %
CMakeTest.scape(". --target install -- -j%i" %
cpu_count(output=conanfile.output)), conanfile.command)
cmake.test()
self.assertIn("cmake --build %s" %
CMakeTest.scape(". --target test -- -j%i" %
cpu_count(output=conanfile.output)),
conanfile.command)
conanfile.should_build = False
cmake.configure()
self.assertNotIn("cd . && cmake", conanfile.command)
cmake.build()
self.assertNotIn("cmake --build %s" %
CMakeTest.scape(". -- -j%i" % cpu_count(output=conanfile.output)),
conanfile.command)
cmake.install()
self.assertNotIn("cmake --build %s" %
CMakeTest.scape(". --target install -- -j%i" %
cpu_count(output=conanfile.output)), conanfile.command)
cmake.test()
self.assertIn("cmake --build %s" %
CMakeTest.scape(". --target test -- -j%i" %
cpu_count(output=conanfile.output)),
conanfile.command)
conanfile.should_install = True
conanfile.should_test = False
cmake.configure()
self.assertNotIn("cd . && cmake", conanfile.command)
cmake.build()
self.assertNotIn("cmake --build %s" %
CMakeTest.scape(". -- -j%i" % cpu_count(output=conanfile.output)),
conanfile.command)
cmake.install()
self.assertIn("cmake --build %s" %
CMakeTest.scape(". --target install -- -j%i" %
cpu_count(output=conanfile.output)), conanfile.command)
cmake.test()
self.assertNotIn("cmake --build %s" %
CMakeTest.scape(". --target test -- -j%i" %
cpu_count(output=conanfile.output)), conanfile.command)
def test_conan_run_tests(self):
conanfile = ConanFileMock()
conanfile.settings = Settings()
conanfile.should_test = True
cmake = CMake(conanfile, generator="Unix Makefiles")
with tools.environment_append({"CONAN_RUN_TESTS": "0"}):
cmake.test()
self.assertIsNone(conanfile.command)
def test_cmake_generator(self):
conanfile = ConanFileMock()
conanfile.settings = Settings()
with tools.environment_append({"CONAN_CMAKE_GENERATOR": "My CMake Generator"}):
cmake = CMake(conanfile)
self.assertIn('-G "My CMake Generator"', cmake.command_line)
def test_cmake_generator_intel(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "intel"
settings.compiler.version = "19"
settings.compiler.base = "Visual Studio"
settings.compiler.base.version = "15"
settings.arch = "x86_64"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
self.assertIn('-G "Visual Studio 15 2017 Win64"', cmake.command_line)
self.assertIn('-T "Intel C++ Compiler 19.0', cmake.command_line)
def test_cmake_custom_generator_intel(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "intel"
settings.compiler.version = "19"
settings.compiler.base = "Visual Studio"
settings.compiler.base.version = "15"
settings.arch = "x86_64"
conanfile = ConanFileMock()
conanfile.settings = settings
with tools.environment_append({"CONAN_CMAKE_GENERATOR": "My CMake Generator"}):
cmake = CMake(conanfile)
self.assertIn('-G "My CMake Generator"', cmake.command_line)
self.assertNotIn('-G "Visual Studio 15 2017" -A "x64"', cmake.command_line)
self.assertNotIn('-T "Intel C++ Compiler 19.0', cmake.command_line)
@parameterized.expand([("SunOS", "sparcv9", "sparc"),
("AIX", "ppc64", "ppc32"),
("SunOS", "x86_64", "x86")])
def test_cmake_not_cross_compile(self, os_build, arch_build, arch):
# https://github.com/conan-io/conan/issues/8052
settings = Settings.loads(get_default_settings_yml())
settings.os = os_build
settings.os_build = os_build
settings.compiler = "gcc"
settings.compiler.version = "9.2"
settings.compiler.libcxx = "libstdc++"
settings.arch = arch
settings.arch_build = arch_build
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
self.assertNotIn('CMAKE_SYSTEM_NAME', cmake.command_line)
self.assertIn('-G "Unix Makefiles"', cmake.command_line)
def test_cmake_generator_platform(self):
conanfile = ConanFileMock()
conanfile.settings = Settings()
with tools.environment_append({"CONAN_CMAKE_GENERATOR": "Green Hills MULTI",
"CONAN_CMAKE_GENERATOR_PLATFORM": "My CMake Platform"}):
cmake = CMake(conanfile)
self.assertIn('-G "Green Hills MULTI" -A "My CMake Platform"', cmake.command_line)
def test_cmake_generator_platform_override(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.arch = "x86"
conanfile = ConanFileMock()
conanfile.settings = settings
with tools.environment_append({"CONAN_CMAKE_GENERATOR_PLATFORM": "Win64"}):
cmake = CMake(conanfile)
self.assertIn('-G "Visual Studio 15 2017" -A "Win64"', cmake.command_line)
def test_cmake_generator_argument(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.compiler.toolset = "v141"
settings.arch = "x86_64"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile, generator="Visual Studio 16 2019")
self.assertIn('-G "Visual Studio 16 2019" -A "x64"', cmake.command_line)
cmake.build()
self.assertIn("/verbosity:minimal", conanfile.command)
cmake = CMake(conanfile, generator="Visual Studio 9 2008")
self.assertIn('-G "Visual Studio 9 2008 Win64"', cmake.command_line)
cmake.build()
self.assertNotIn("verbosity", conanfile.command)
def test_cmake_generator_platform_gcc(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.os_build = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "8"
settings.compiler.libcxx = "libstdc++"
settings.arch = "x86"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
self.assertIn('-G "Unix Makefiles"', cmake.command_line)
self.assertNotIn('-A', cmake.command_line)
@parameterized.expand([('x86', 'Visual Studio 15 2017'),
('x86_64', 'Visual Studio 15 2017 Win64'),
('armv7', 'Visual Studio 15 2017 ARM')])
def test_cmake_generator_platform_vs2017(self, arch, generator):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.arch = arch
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
self.assertIn('-G "%s"' % generator, cmake.command_line)
self.assertNotIn('-A', cmake.command_line)
@parameterized.expand([('x86', 'Win32'),
('x86_64', 'x64'),
('armv7', 'ARM'),
('armv8', 'ARM64')])
def test_cmake_generator_platform_vs2019(self, arch, pf):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "16"
settings.arch = arch
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
self.assertIn('-G "Visual Studio 16 2019" -A "%s"' % pf, cmake.command_line)
def test_cmake_generator_platform_vs2019_with_ninja(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "16"
settings.arch = "x86_64"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile, generator="Ninja")
self.assertIn('-G "Ninja"', cmake.command_line)
self.assertNotIn("-A", cmake.command_line)
@parameterized.expand([('arm',),
('ppc',),
('86',)])
def test_cmake_generator_platform_other(self, arch):
conanfile = ConanFileMock()
conanfile.settings = Settings()
with tools.environment_append({"CONAN_CMAKE_GENERATOR": "Green Hills MULTI",
"CONAN_CMAKE_GENERATOR_PLATFORM": arch}):
cmake = CMake(conanfile)
self.assertIn('-G "Green Hills MULTI" -A "%s"' % arch, cmake.command_line)
@parameterized.expand([('Ninja',),
('NMake Makefiles',),
('NMake Makefiles JOM',)
])
def test_generator_platform_with_unsupported_generator(self, generator):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.arch = "x86"
settings.compiler.toolset = "v140"
conanfile = ConanFileMock()
conanfile.settings = settings
with self.assertRaises(ConanException):
cmake = CMake(conanfile, generator=generator, generator_platform="x64")
_ = cmake.command_line
def test_cmake_fpic(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "6.3"
settings.arch = "x86"
def assert_fpic(the_settings, input_shared, input_fpic, expected_option):
options = []
values = {}
if input_shared is not None:
options.append('"shared": [True, False]')
values["shared"] = input_shared
if input_fpic is not None:
options.append('"fPIC": [True, False]')
values["fPIC"] = input_fpic
conanfile = ConanFileMock(options='{%s}' % ", ".join(options),
options_values=values)
conanfile.settings = the_settings
cmake = CMake(conanfile)
cmake.configure()
if expected_option is not None:
self.assertEqual(cmake.definitions["CONAN_CMAKE_POSITION_INDEPENDENT_CODE"],
expected_option)
else:
self.assertNotIn("CONAN_CMAKE_POSITION_INDEPENDENT_CODE", cmake.definitions)
# Test shared=False and fpic=False
assert_fpic(settings, input_shared=False, input_fpic=False, expected_option="OFF")
# Test shared=True and fpic=False
assert_fpic(settings, input_shared=True, input_fpic=False, expected_option="ON")
# Test shared=True and fpic=True
assert_fpic(settings, input_shared=True, input_fpic=True, expected_option="ON")
# Test shared not defined and fpic=True
assert_fpic(settings, input_shared=None, input_fpic=True, expected_option="ON")
# Test shared not defined and fpic not defined
assert_fpic(settings, input_shared=None, input_fpic=None, expected_option=None)
# Test shared True and fpic not defined
assert_fpic(settings, input_shared=True, input_fpic=None, expected_option=None)
# Test nothing in Windows
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.arch = "x86_64"
assert_fpic(settings, input_shared=True, input_fpic=True, expected_option=None)
def test_cmake_make_program(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "6.3"
settings.arch = "x86"
settings.build_type = "Release"
conanfile = ConanFileMock()
conanfile.settings = settings
conanfile.source_folder = os.path.join(self.tempdir, "my_cache_source_folder")
conanfile.build_folder = os.path.join(self.tempdir, "my_cache_build_folder")
# Existing make
make_path = os.path.join(self.tempdir, "make")
save(make_path, "")
st = os.stat(make_path)
os.chmod(make_path, st.st_mode | stat.S_IEXEC)
with tools.environment_append({"CONAN_MAKE_PROGRAM": make_path}):
cmake = CMake(conanfile)
self.assertEqual(cmake.definitions["CMAKE_MAKE_PROGRAM"], make_path)
# Not existing make
with tools.environment_append({"CONAN_MAKE_PROGRAM": "fake_path/make"}):
cmake = CMake(conanfile)
self.assertNotIn("CMAKE_MAKE_PROGRAM", cmake.definitions)
self.assertIn("The specified make program 'fake_path/make' cannot be found",
conanfile.output)
def test_folders(self):
def quote_var(var):
return "'%s'" % var if platform.system() != "Windows" else var
settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "6.3"
settings.arch = "x86"
settings.build_type = "Release"
conanfile = ConanFileMock()
conanfile.settings = settings
conanfile.source_folder = os.path.join(self.tempdir, "my_cache_source_folder")
conanfile.build_folder = os.path.join(self.tempdir, "my_cache_build_folder")
with tools.chdir(self.tempdir):
linux_stuff = ""
if platform.system() != "Linux":
linux_stuff = '-DCMAKE_SYSTEM_NAME="Linux" ' \
'-DCMAKE_SYSTEM_PROCESSOR="i386" ' \
'-DCMAKE_SYSROOT="/path/to/sysroot" '
generator = "MinGW Makefiles" if platform.system() == "Windows" else "Unix Makefiles"
flags = '{} -DCONAN_COMPILER="gcc" ' \
'-DCONAN_COMPILER_VERSION="6.3" ' \
'-DCONAN_CXX_FLAGS="-m32" -DCONAN_SHARED_LINKER_FLAGS="-m32" ' \
'-DCONAN_C_FLAGS="-m32" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" ' \
'-DCONAN_EXPORTED="1"'
flags_in_local_cache = flags.format('-D' + cmake_in_local_cache_var_name + '="ON"')
flags_no_local_cache = flags.format('-D' + cmake_in_local_cache_var_name + '="OFF"')
base_cmd = 'cmake -G "{generator}" -DCMAKE_BUILD_TYPE="Release" {linux_stuff}' \
'{{flags}} -Wno-dev'
base_cmd = base_cmd.format(generator=generator, linux_stuff=linux_stuff)
full_cmd = "cd {build_expected} && {base_cmd} {source_expected}"
build_expected = quote_var("build")
source_expected = quote_var("../subdir")
cmake = CMake(conanfile)
cmake.configure(source_dir="../subdir", build_dir="build")
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_no_local_cache)))
cmake = CMake(conanfile)
cmake.configure(build_dir="build")
build_expected = quote_var("build")
source_expected = quote_var(os.path.join(self.tempdir, "my_cache_source_folder"))
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_no_local_cache)))
cmake = CMake(conanfile)
cmake.configure()
build_expected = quote_var(os.path.join(self.tempdir, "my_cache_build_folder"))
source_expected = quote_var(os.path.join(self.tempdir, "my_cache_source_folder"))
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_no_local_cache)))
cmake = CMake(conanfile)
cmake.configure(source_folder="source", build_folder="build")
build_expected = quote_var(os.path.join(os.path.join(self.tempdir,
"my_cache_build_folder", "build")))
source_expected = quote_var(os.path.join(os.path.join(self.tempdir,
"my_cache_source_folder",
"source")))
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_no_local_cache)))
conanfile.in_local_cache = True
cmake = CMake(conanfile)
cmake.configure(source_folder="source", build_folder="build",
cache_build_folder="rel_only_cache")
build_expected = quote_var(os.path.join(self.tempdir, "my_cache_build_folder",
"rel_only_cache"))
source_expected = quote_var(os.path.join(self.tempdir, "my_cache_source_folder",
"source"))
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_in_local_cache)))
conanfile.in_local_cache = False
cmake = CMake(conanfile)
cmake.configure(source_folder="source", build_folder="build",
cache_build_folder="rel_only_cache")
build_expected = quote_var(os.path.join(self.tempdir, "my_cache_build_folder", "build"))
source_expected = quote_var(os.path.join(self.tempdir, "my_cache_source_folder",
"source"))
self.assertEqual(conanfile.command,
full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(flags=flags_no_local_cache)))
conanfile.in_local_cache = True
cmake = CMake(conanfile)
cmake.configure(build_dir="build", cache_build_folder="rel_only_cache")
build_expected = quote_var(os.path.join(self.tempdir, "my_cache_build_folder",
"rel_only_cache"))
source_expected = quote_var(os.path.join(self.tempdir, "my_cache_source_folder"))
self.assertEqual(conanfile.command, full_cmd.format(build_expected=build_expected,
source_expected=source_expected,
base_cmd=base_cmd.format(
flags=flags_in_local_cache)))
# Raise mixing
with six.assertRaisesRegex(self, ConanException, "Use 'build_folder'/'source_folder'"):
cmake = CMake(conanfile)
cmake.configure(source_folder="source", build_dir="build")
def test_build_type_force(self):
# 1: No multi-config generator
settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "6.3"
settings.arch = "x86"
settings.build_type = "Release"
conanfile = ConanFileMock()
conanfile.settings = settings
# 2: build_type from settings
cmake = CMake(conanfile)
self.assertNotIn('WARN: Forced CMake build type ', conanfile.output)
self.assertEqual(cmake.build_type, "Release")
# 2: build_type from attribute
cmake.build_type = "Debug"
expected_output = "WARN: Forced CMake build type ('Debug') different from the settings " \
"build type ('Release')"
self.assertIn(expected_output, conanfile.output)
self.assertEqual(cmake.build_type, "Debug")
self.assertIn('-DCMAKE_BUILD_TYPE="Debug"', cmake.command_line)
# 2: build_type from constructor
cmake = CMake(conanfile, build_type="Debug")
expected_output = "WARN: Forced CMake build type ('Debug') different from the settings " \
"build type ('Release')"
self.assertIn(expected_output, conanfile.output)
self.assertEqual(cmake.build_type, "Debug")
self.assertIn('-DCMAKE_BUILD_TYPE="Debug"', cmake.command_line)
# 1: Multi-config generator
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "15"
settings.arch = "x86"
settings.build_type = "Release"
conanfile = ConanFileMock()
conanfile.settings = settings
# 2: build_type from settings
cmake = CMake(conanfile)
self.assertNotIn('-DCMAKE_BUILD_TYPE="Release"', cmake.command_line)
self.assertIn("--config Release", cmake.build_config)
# 2: build_type from attribute
cmake.build_type = "Debug"
self.assertIn(expected_output, conanfile.output)
self.assertEqual(cmake.build_type, "Debug")
self.assertNotIn('-DCMAKE_BUILD_TYPE="Debug"', cmake.command_line)
self.assertIn("--config Debug", cmake.build_config)
# 2: build_type from constructor
cmake = CMake(conanfile, build_type="Debug")
self.assertIn(expected_output, conanfile.output)
self.assertEqual(cmake.build_type, "Debug")
self.assertNotIn('-DCMAKE_BUILD_TYPE="Debug"', cmake.command_line)
self.assertIn("--config Debug", cmake.build_config)
def test_loads_default(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "12"
settings.arch = "x86"
conanfile = ConanFileMock()
conanfile.settings = settings
def check(text, build_config, generator=None, set_cmake_flags=False):
the_os = str(settings.os)
arch = str(settings.arch)
os_ver = str(settings.os.version) if settings.get_safe('os.version') else None
for cmake_system_name in (True, False):
cross_ver = ("-DCMAKE_SYSTEM_VERSION=\"%s\" " % os_ver) if os_ver else ""
# FIXME: This test is complicated to maintain and see the logic, lets simplify it
cross = ""
skip_x64_x86 = the_os in ['Windows', 'Linux']
if cmake_system_name and cross_building(conanfile, skip_x64_x86=skip_x64_x86):
if the_os in ["WindowsStore", "WindowsCE", "Windows"]:
arch_map = {"armv8": "ARM64",
"armv7": "ARM",
"x86": "x86",
"x86_64": "AMD64"}
else:
arch_map = {"armv8": "aarch64",
"armv7": "arm",
"x86": "i386",
"x86_64": "x86_64",
"sparcv9": "sparc64"}
cross = ("-DCMAKE_SYSTEM_NAME=\"%s\" "
"-DCMAKE_SYSTEM_PROCESSOR=\"%s\" "
"%s-DCMAKE_SYSROOT=\"/path/to/sysroot\" "
% ({"Macos": "Darwin"}.get(the_os, the_os), arch_map.get(arch, arch), cross_ver))
cmake = CMake(conanfile, generator=generator, cmake_system_name=cmake_system_name,
set_cmake_flags=set_cmake_flags)
new_text = text.replace("-DCONAN_IN_LOCAL_CACHE", "%s-DCONAN_IN_LOCAL_CACHE" % cross)
if "Visual Studio" in text:
cores = ('-DCONAN_CXX_FLAGS="/MP{0}" '
'-DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count(conanfile.output)))
new_text = new_text.replace('-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON"',
'%s-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON"' % cores)
self.assertEqual(new_text, cmake.command_line)
self.assertEqual(build_config, cmake.build_config)
check('-G "Visual Studio 12 2013" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"")
check('-G "Custom Generator" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
'', generator="Custom Generator")
check('-G "Custom Generator" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
'', generator="Custom Generator", set_cmake_flags=True)
settings.build_type = "Debug"
check('-G "Visual Studio 12 2013" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
'--config Debug')
settings.arch = "x86_64"
check('-G "Visual Studio 12 2013 Win64" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
'--config Debug')
settings.compiler = "gcc"
settings.compiler.version = "4.8"
cmakegen = "MinGW Makefiles" if platform.system() == "Windows" else "Unix Makefiles"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" '
'-Wno-dev' % cmakegen, "")
settings.os = "Linux"
settings.arch = "x86"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="gcc" '
'-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS="-m32" '
'-DCONAN_SHARED_LINKER_FLAGS="-m32" -DCONAN_C_FLAGS="-m32" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "armv7"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="gcc" '
'-DCONAN_COMPILER_VERSION="4.8" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "x86_64"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="gcc" '
'-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="gcc" '
'-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_CXX_FLAGS="-m64" -DCMAKE_SHARED_LINKER_FLAGS="-m64" -DCMAKE_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" '
'-Wno-dev' % cmakegen,
"", set_cmake_flags=True)
settings.os = "FreeBSD"
settings.compiler = "clang"
settings.compiler.version = "3.8"
settings.arch = "x86"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="clang" '
'-DCONAN_COMPILER_VERSION="3.8" -DCONAN_CXX_FLAGS="-m32" '
'-DCONAN_SHARED_LINKER_FLAGS="-m32" -DCONAN_C_FLAGS="-m32" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "x86_64"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="clang" '
'-DCONAN_COMPILER_VERSION="3.8" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.os = "SunOS"
settings.compiler = "sun-cc"
settings.compiler.version = "5.10"
settings.arch = "x86"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="sun-cc" '
'-DCONAN_COMPILER_VERSION="5.10" -DCONAN_CXX_FLAGS="-m32" '
'-DCONAN_SHARED_LINKER_FLAGS="-m32" -DCONAN_C_FLAGS="-m32" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "x86_64"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" '
'-DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="sun-cc" '
'-DCONAN_COMPILER_VERSION="5.10" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "sparc"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="sun-cc" '
'-DCONAN_COMPILER_VERSION="5.10" -DCONAN_CXX_FLAGS="-m32" '
'-DCONAN_SHARED_LINKER_FLAGS="-m32" -DCONAN_C_FLAGS="-m32" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "sparcv9"
check('-G "%s" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="sun-cc" '
'-DCONAN_COMPILER_VERSION="5.10" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev' % cmakegen,
"")
settings.arch = "sparc"
settings.compiler = "Visual Studio"
settings.compiler.version = "12"
settings.os = "WindowsStore"
settings.os.version = "8.1"
settings.build_type = "Debug"
check('-G "Visual Studio 12 2013" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"--config Debug")
settings.os.version = "10.0"
check('-G "Visual Studio 12 2013" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"--config Debug")
settings.compiler.version = "15"
settings.arch = "armv8"
check('-G "Visual Studio 15 2017" -A "ARM64" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="15" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"--config Debug")
settings.arch = "x86_64"
check('-G "Visual Studio 15 2017 Win64" -DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="15" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"--config Debug")
settings.compiler = "Visual Studio"
settings.compiler.version = "9"
settings.os = "WindowsCE"
settings.os.platform = "Your platform name (ARMv4I)"
settings.os.version = "7.0"
settings.build_type = "Debug"
check('-G "Visual Studio 9 2008" '
'-A "Your platform name (ARMv4I)" '
'-DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="9" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev',
"--config Debug")
def test_deleted_os(self):
partial_settings = """
os: [Linux]
arch: [x86_64]
compiler:
gcc:
version: ["4.9"]
build_type: [ Release]
"""
settings = Settings.loads(partial_settings)
settings.os = "Linux"
settings.compiler = "gcc"
settings.compiler.version = "4.9"
settings.arch = "x86_64"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
generator = "Unix" if platform.system() != "Windows" else "MinGW"
cross = ("-DCMAKE_SYSTEM_NAME=\"Linux\" "
"-DCMAKE_SYSTEM_PROCESSOR=\"x86_64\" "
"-DCMAKE_SYSROOT=\"/path/to/sysroot\" "
if platform.system() != "Linux" else "")
self.assertEqual('-G "%s Makefiles" %s-DCONAN_IN_LOCAL_CACHE="OFF" '
'-DCONAN_COMPILER="gcc" '
'-DCONAN_COMPILER_VERSION="4.9" -DCONAN_CXX_FLAGS="-m64" '
'-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" '
'-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" '
'-Wno-dev' % (generator, cross),
cmake.command_line)
def test_sysroot(self):
settings = Settings.loads(get_default_settings_yml())
conanfile = ConanFileMock()
conanfile.settings = settings
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "12"
settings.arch = "x86"
if platform.system() == "Windows":
cmake = CMake(conanfile)
self.assertNotIn("-DCMAKE_SYSROOT=", cmake.flags)
# Now activate cross build and check sysroot and system processor
with(tools.environment_append({"CONAN_CMAKE_SYSTEM_NAME": "Android",
"CONAN_CMAKE_SYSTEM_PROCESSOR": "somevalue"})):
cmake = CMake(conanfile)
self.assertEqual(cmake.definitions["CMAKE_SYSROOT"], "/path/to/sysroot")
self.assertEqual(cmake.definitions["CMAKE_SYSTEM_PROCESSOR"], "somevalue")
def test_sysroot_envvar(self):
settings = Settings.loads(get_default_settings_yml())
conanfile = ConanFileMock()
conanfile.settings = settings
settings.os = "Linux"
settings.os_build = "Windows"
settings.compiler = "gcc"
settings.compiler.version = "5"
settings.arch_build = "x86_64"
settings.arch = "armv7"
# Now activate cross build and check sysroot and system processor
with(tools.environment_append({"CONAN_CMAKE_SYSROOT": "/path/to/var/sysroot"})):
cmake = CMake(conanfile)
self.assertEqual(cmake.definitions["CMAKE_SYSROOT"], "/path/to/var/sysroot")
def test_deprecated_behaviour(self):
""""Remove when deprecate the old settings parameter to CMake and
conanfile to configure/build/test"""
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
conanfile = ConanFileMock()
conanfile.settings = settings
with self.assertRaises(ConanException):
CMake(settings)
def test_cores_ancient_visual(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Windows"
settings.compiler = "Visual Studio"
settings.compiler.version = "9"
settings.compiler.runtime = "MDd"
settings.arch = "x86"
settings.build_type = None
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
cmake.build()
self.assertNotIn("/m", conanfile.command)
settings.compiler.version = "10"
cmake = CMake(conanfile)
cmake.build()
self.assertIn("/m", conanfile.command)
def test_convenient_functions(self):
settings = Settings.loads(get_default_settings_yml())
settings.os = "Android"
settings.os.api_level = 16
settings.os_build = "Windows" # Here we are declaring we are cross building
settings.compiler = "gcc"
settings.compiler.version = "5.4"
settings.arch = "armv7"
settings.build_type = None
if platform.system() == 'Windows':
dot_dir = "."
tempdir = self.tempdir
else:
dot_dir = "'.'"
tempdir = "'" + self.tempdir + "'"
conanfile = ConanFileMock()
conanfile.settings = settings
cmake = CMake(conanfile)
cross = '-DCMAKE_SYSTEM_NAME="Android"' \
' -DCMAKE_SYSTEM_PROCESSOR="arm"' \
' -DCMAKE_SYSTEM_VERSION="{0}"' \
' -DCMAKE_SYSROOT="/path/to/sysroot"' \
' -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a"' \
' -DANDROID_ABI="armeabi-v7a"' \
' -DANDROID_PLATFORM="android-{0}"' \
' -DANDROID_TOOLCHAIN="{1}"' \
' -DANDROID_STL="none"'.format(settings.os.api_level, settings.compiler)
target_test = CMakeTest.scape('--target test')
cmake.configure()
self.assertEqual('cd {0} && cmake -G "MinGW Makefiles" '