source: sasview/sasmodels/generate_cmake.py @ f349f85

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since f349f85 was 3a39c2e, checked in by krzywon, 10 years ago

Next iteration of the SANS→SAS is complete.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[26e0249]1"""
2    Script to generate a CMakeLists.txt file for cmake
3   
4    python generate_cmake.py
5    cd [your build location not in the source tree]
6    cmake [path to directory containing CMakeLists.txt]
7    make
8   
9    That will produce a library libModels.a
10"""
11import os
12f = open("CMakeLists.txt", "w")
13
[3a39c2e]14cmakelist = """# CMakeLists for SAS models
[26e0249]15cmake_minimum_required (VERSION 2.6)
[3a39c2e]16project (SasModels)
[26e0249]17
18# Version number
[3a39c2e]19set (SasModels_VERSION_MAJOR 1)
20set (SasModels_VERSION_MAJOR 0)
[26e0249]21
22set (SRC_FILES
23"""
24
25source_dirs = ["src/c_models",
26               "src/libigor"]
27excluded_src = ["c_models.cpp",
28                "disperser.c",
29                "winFuncs.c"]
30
31for src_dir in source_dirs:
32    for item in os.listdir(src_dir):
33        if item in excluded_src:
34            continue
35        ext = os.path.splitext(item)[1]
36        if ext in [".c",".cpp"]:
37            cmakelist += "    %s\n" % os.path.join(src_dir, item)
38
39cmakelist += "    )\n\n"   
40
41cmakelist += "set ( INC_FILES\n"   
42
43include_dirs = ["src/c_models",
[503a972]44                "include",
[26e0249]45                "src/libigor"]
46
47for inc_dir in include_dirs:
48    for item in os.listdir(inc_dir):
49        ext = os.path.splitext(item)[1]
50        if ext in [".h",".hh"]:
51            cmakelist += "    %s\n" % os.path.join(inc_dir, item)
52   
53cmakelist += """
54)
55   
[503a972]56include_directories (src/libigor include src/c_models)
[26e0249]57
58# Add the target for this directory
[62dc94b]59add_library ( models ${SRC_FILES} ${INC_FILES})
60add_executable( libraryTest test/library_test.cpp  ${INC_FILES})
61ADD_DEFINITIONS(-D__MODELS_STANDALONE__)
62ADD_DEPENDENCIES(libraryTest models)
63TARGET_LINK_LIBRARIES(libraryTest models)
[26e0249]64"""
65
66f.write(cmakelist)
67f.close()
68
69   
Note: See TracBrowser for help on using the repository browser.