from conans import ConanFile, CMake


class BPTreeConan(ConanFile):

    name = 'bptree'
    version = '0.0.0'
    url = 'https://github.com/jason2506/bptree-cpp'
    license = 'MIT'
    author = 'Chi-En Wu'

    settings = ('os', 'compiler', 'build_type', 'arch')
    generators = ('cmake', 'txt', 'env')
    options = {
        'enable_conan': [True, False],
    }
    default_options = (
        'gtest:shared=False',
        'enable_conan=True',
    )

    exports = (
        'CMakeLists.txt',
        'cmake/*.cmake',
        'include/*.hpp',
        'test/CMakeLists.txt',
        'test/*.cpp',
    )

    def requirements(self):
        if self.scope.dev and self.scope.build_tests:
            self.requires('gtest/1.8.0@lasote/stable', private=True)

    def build(self):
        extra_opts = []
        extra_opts.append('-DENABLE_CONAN={}'.format(
            self.options.enable_conan,
        ))
        extra_opts.append('-DBUILD_TESTING={}'.format(
            bool(self.scope.dev and self.scope.build_tests),
        ))
        extra_opts.append('-DCMAKE_INSTALL_PREFIX="{}"'.format(
            self.package_folder,
        ))

        cmake = CMake(self.settings)
        self.run('cmake "{src_dir}" {opts} {extra_opts}'.format(
            src_dir=self.conanfile_directory,
            opts=cmake.command_line,
            extra_opts=' '.join(extra_opts),
        ))
        self.run('cmake --build . {}'.format(cmake.build_config))

    def package(self):
        self.run('cmake --build . --target install')

@@ -294,16 +294,36 @@
 txt'
-, 'env')
+)%0A    no_copy_source = True%0A
 %0A   
@@ -670,44 +670,15 @@
 elf.
-scope.dev and self.scope.build_tests
+develop
 :%0A  
@@ -732,22 +732,8 @@
 ble'
-, private=True
 )%0A%0A 
@@ -765,88 +765,146 @@
    e
-xtra_opts = %5B%5D%0A        extra_opts.append('-DENABLE_CONAN=%7B%7D'.format(%0A           
+nable_testing = 'gtest' in self.deps_cpp_info.deps%0A%0A        cmake = CMake(self)%0A        cmake.configure(defs=%7B%0A            'ENABLE_CONAN':
  sel
@@ -939,125 +939,43 @@
     
-))%0A
     
-    extra_opts.append('-DBUILD_TESTING=%7B%7D'.format(%0A            bool(self.scope.dev and self.scope.build
+'BUILD_TESTING': enable
 _test
-s)
+ing
 ,%0A  
@@ -972,33 +972,33 @@
 esting,%0A        
-)
+%7D
 )%0A        extra_
@@ -995,415 +995,181 @@
     
-extra_opts.append('-DCMAKE_INSTALL_PREFIX=%22%7B%7D%22'.format(%0A            self.package_folder,%0A        ))%0A%0A
+cmake.build()%0A        if enable_testing:%0A     
        
- 
 cmake
- = CMake(self.settings)%0A        self.run('cmake %22%7Bsrc_dir%7D%22 %7Bopts%7D %7Bextra_opts%7D'.format(%0A            src_dir=self.conanfile_directory,%0A            opts=cmake.command_line,%0A            extra_opts=' '.join(extra_opts),%0A        ))%0A        self.run('cmake --build . %7B%7D'.format(cmake.build_config))
+.test()%0A%0A        cmake.install()%0A%0A    def package(self):%0A        # files are copied by cmake.install()%0A        pass
 %0A%0A  
@@ -1173,32 +1173,35 @@
 %0A    def package
+_id
 (self):%0A        
@@ -1209,44 +1209,23 @@
 elf.
-run('cmake --build . --target install'
+info.header_only(
 )%0A

Migrate `conanfile.py` to newer version