{"action":"created","issue":{"url":"https://api.github.com/repos/Amber-MD/pytraj/issues/1408","repository_url":"https://api.github.com/repos/Amber-MD/pytraj","labels_url":"https://api.github.com/repos/Amber-MD/pytraj/issues/1408/labels{/name}","comments_url":"https://api.github.com/repos/Amber-MD/pytraj/issues/1408/comments","events_url":"https://api.github.com/repos/Amber-MD/pytraj/issues/1408/events","html_url":"https://github.com/Amber-MD/pytraj/pull/1408","id":244819393,"number":1408,"title":"Add CMake build system changes","user":{"login":"multiplemonomials","id":2099358,"avatar_url":"https://avatars1.githubusercontent.com/u/2099358?v=4","gravatar_id":"","url":"https://api.github.com/users/multiplemonomials","html_url":"https://github.com/multiplemonomials","followers_url":"https://api.github.com/users/multiplemonomials/followers","following_url":"https://api.github.com/users/multiplemonomials/following{/other_user}","gists_url":"https://api.github.com/users/multiplemonomials/gists{/gist_id}","starred_url":"https://api.github.com/users/multiplemonomials/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/multiplemonomials/subscriptions","organizations_url":"https://api.github.com/users/multiplemonomials/orgs","repos_url":"https://api.github.com/users/multiplemonomials/repos","events_url":"https://api.github.com/users/multiplemonomials/events{/privacy}","received_events_url":"https://api.github.com/users/multiplemonomials/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2017-07-22T02:58:50Z","updated_at":"2017-07-22T04:49:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Amber-MD/pytraj/pulls/1408","html_url":"https://github.com/Amber-MD/pytraj/pull/1408","diff_url":"https://github.com/Amber-MD/pytraj/pull/1408.diff","patch_url":"https://github.com/Amber-MD/pytraj/pull/1408.patch"},"body":"The CMake build system requires some changes to pytraj.  In CMake, the location of compiled files is decided by CMake, and is not guaranteed to be consistent.   So, you can't just use the Amber lib directory.  You *almost* had the right setup for CMake to pass in the locations via `CPPTRAJ_LIBDIR` and `CPPTRAJ_HEADERDIR`; I just had to edit `base_setup.py` so that it will use those variables when they are provided even if pytraj is being built inside Amber.\r\n\r\nAlso, I designed the CMake build system to not modify the source directory at all so as to make using Git easier, and I found the `build -b <dir>` argument to Distutils to relocate the Python built files.  However, there doesn't seem to be any way to tell Cython not to put its generated files in the source directory, at least from the command line.  Do you know if it's possible to change the Cython build directory?\r\n\r\nAnother issue I was having was the MinGW compiler throwing errors about being unable to export symbols with names corresponding to each Python file.  It [looks like](https://stackoverflow.com/questions/34689210/error-exporting-symbol-when-building-python-c-extension-in-windows) Distutils expects each Python C extension to define some sort of initialization function.  Currently, the only way to build pytraj on Windows is to screw with your Python installation: in `<python install dir>/Lib/distutils/cygwinccompiler.py`, change line 193 to `if (False and`.  I've set up the CMake system's Miniconda installer to apply this patch automatically, but it would be nice if you could create these functions so we could get away from this hack.\r\n\r\nFinally, if you were wondering, here's a sample of the command that CMake uses to build Pytraj on Windows:\r\n```\r\nenv --unset=AMBERHOME CPPTRAJ_HEADERDIR=<path to cpptraj headers> CPPTRAJ_LIBDIR=<directory containing libcpptraj> CC=<cmake c compiler> CXX=<cmake cxx compiler> python setup.py build_ext --no-setuptools -b <path to build dir> --disable-openmp -compiler=mingw32 -DMS_WIN64\r\n```"},"comment":{"url":"https://api.github.com/repos/Amber-MD/pytraj/issues/comments/317154995","html_url":"https://github.com/Amber-MD/pytraj/pull/1408#issuecomment-317154995","issue_url":"https://api.github.com/repos/Amber-MD/pytraj/issues/1408","id":317154995,"user":{"login":"multiplemonomials","id":2099358,"avatar_url":"https://avatars1.githubusercontent.com/u/2099358?v=4","gravatar_id":"","url":"https://api.github.com/users/multiplemonomials","html_url":"https://github.com/multiplemonomials","followers_url":"https://api.github.com/users/multiplemonomials/followers","following_url":"https://api.github.com/users/multiplemonomials/following{/other_user}","gists_url":"https://api.github.com/users/multiplemonomials/gists{/gist_id}","starred_url":"https://api.github.com/users/multiplemonomials/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/multiplemonomials/subscriptions","organizations_url":"https://api.github.com/users/multiplemonomials/orgs","repos_url":"https://api.github.com/users/multiplemonomials/repos","events_url":"https://api.github.com/users/multiplemonomials/events{/privacy}","received_events_url":"https://api.github.com/users/multiplemonomials/received_events","type":"User","site_admin":false},"created_at":"2017-07-22T04:49:31Z","updated_at":"2017-07-22T04:49:31Z","body":"The thing is, the CMake build script I put in here isn't a complete build system.  It's just a small piece of the scripts in the main Amber repository.  While you can run it by itself, it uses lots of variables and functions which are defined by the top-level configuration scripts"}}
{"actor":{"display_login":"multiplemonomials"}}