Skip to content

Commit

Permalink
added BUILD_TYPE arg, and added tests for ARCH, BUILD_TYPE and NO_OUT…
Browse files Browse the repository at this point in the history
…PUT_DIRS too
  • Loading branch information
memsharded committed Feb 14, 2018
1 parent 0910dd9 commit 198da3e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
14 changes: 9 additions & 5 deletions conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ function(conan_cmake_settings result)

message(STATUS "Conan ** WARNING** : This detection of settings from cmake is experimental and incomplete. "
"Please check 'conan.cmake' and contribute")
set(arch "${ARGN}")

parse_arguments(${ARGV})
set(arch ${ARGUMENTS_ARCH})

if(CONAN_CMAKE_MULTI)
set(_SETTINGS -g cmake_multi)
else()
set(_SETTINGS -g cmake)
endif()
if(CMAKE_BUILD_TYPE)
if(ARGUMENTS_BUILD_TYPE)
set(_SETTINGS ${_SETTINGS} -s build_type=${ARGUMENTS_BUILD_TYPE})
elseif(CMAKE_BUILD_TYPE)
set(_SETTINGS ${_SETTINGS} -s build_type=${CMAKE_BUILD_TYPE})
else()
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
Expand Down Expand Up @@ -252,7 +256,7 @@ endfunction()

macro(parse_arguments)
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_OUTPUT_DIRS)
set(oneValueArgs CONANFILE DEBUG_PROFILE RELEASE_PROFILE PROFILE ARCH)
set(oneValueArgs CONANFILE DEBUG_PROFILE RELEASE_PROFILE PROFILE ARCH BUILD_TYPE)
set(multiValueArgs REQUIRES OPTIONS IMPORTS BUILD CONAN_COMMAND)
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
endmacro()
Expand Down Expand Up @@ -382,12 +386,12 @@ macro(conan_cmake_run)
conan_cmake_setup_conanfile(${ARGV})
if(CONAN_CMAKE_MULTI)
foreach(CMAKE_BUILD_TYPE "Release" "Debug")
conan_cmake_settings(settings ${ARGUMENTS_ARCH})
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
endforeach()
set(CMAKE_BUILD_TYPE)
else()
conan_cmake_settings(settings ${ARGUMENTS_ARCH})
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
endif()
endif()
Expand Down
67 changes: 67 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,70 @@ def test_vs_toolset(self):
run("cmake --build . --config Release")
cmd = os.sep.join([".", "bin", "main"])
run(cmd)

def test_arch(self):
content = """#set(CMAKE_CXX_COMPILER_WORKS 1)
#set(CMAKE_CXX_ABI_COMPILED 1)
message(STATUS "COMPILING-------")
cmake_minimum_required(VERSION 2.8)
project(conan_wrapper CXX)
include(conan.cmake)
conan_cmake_run(BASIC_SETUP
BUILD missing
ARCH armv7)
if(NOT ${CONAN_SETTINGS_ARCH} STREQUAL "armv7")
message(FATAL_ERROR "ARCHITECTURE IS NOT armv7")
endif()
"""
save("CMakeLists.txt", content)

os.makedirs("build")
os.chdir("build")
run("cmake .. %s -DCMAKE_BUILD_TYPE=Release" % (generator))


def test_no_output_dir(self):
content = """set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
message(STATUS "COMPILING-------")
cmake_minimum_required(VERSION 2.8)
project(conan_wrapper CXX)
include(conan.cmake)
conan_cmake_run(BASIC_SETUP
NO_OUTPUT_DIRS
BUILD missing)
if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
message(FATAL_ERROR "OUTPUT_DIRS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif()
"""
save("CMakeLists.txt", content)

os.makedirs("build")
os.chdir("build")
run("cmake .. %s -DCMAKE_BUILD_TYPE=Release" % (generator))

def test_build_type(self):
content = """set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
message(STATUS "COMPILING-------")
cmake_minimum_required(VERSION 2.8)
project(conan_wrapper CXX)
include(conan.cmake)
conan_cmake_run(BASIC_SETUP
BUILD_TYPE None)
if(NOT ${CONAN_SETTINGS_BUILD_TYPE} STREQUAL "None")
message(FATAL_ERROR "CMAKE BUILD TYPE is not None!")
endif()
"""
save("CMakeLists.txt", content)

os.makedirs("build")
os.chdir("build")
run("cmake .. %s -DCMAKE_BUILD_TYPE=Release" % (generator))

0 comments on commit 198da3e

Please sign in to comment.